Regular expression to find input value in scala

1.1k views Asked by At

I'm getting a response as below

while making request

<!-- template name: form.autopost.template.html -->

<html>
    <head>
    <title>Submit Form</title>
    </head>
    <body onload="javascript:document.forms[0].submit()">
       <noscript>
            <p>
                <strong>Note:</strong> Since your browser does not support JavaScript,
                        you must press the Resume button once to proceed.
            </p>
        </noscript>
        <form method="post" action="https://myurl/">
                        <input type="hidden" name="myvar" value="T1RLAQKBY"/>
                        <noscript><input type="submit" value="Resume"/></noscript>
        </form>
    </body>
</html>

How can I get value of myvar name using scala. Can anyone suggest me regex for this.

I'm done code as below but it does not gives me proper value it says failed: regex( .* value=.* ).exists, found nothing

.exec(
                http("get value")
                .get("https://some/url")
               .check(regex("""<input type="hidden" name="myvar" value="(.*)" />""").saveAs("input"))
            )
1

There are 1 answers

0
Sergii Lagutin On BEST ANSWER

Delete extra space ' ' before closing angle />:

.exec(
            http("get value")
            .get("https://some/url")
           .check(regex("""<input type="hidden" name="myvar" value="(.*)"/>""").saveAs("input"))
        )