Dear monks,

I am trying to match a string within some HTML but seem to be having some trouble doing so. The following is part of the HTML source that I am looking to match:

name="challenge" value="26eca68705b3b0c76a6d0602937ac524"

I want to grab the string for value. I am using grouping in my regexp and expect therefore that $1 will return 26eca68...etc, essentially the string in between the quotes for the value parameter. Here is the regexp I am using:

$returned_data =~ s/\n//g; my $c_code = $returned_data; $c_code =~ m/name="challenge" value="(.*)"/; #" print $1 . "\n";
When $1 is printed it does not just print the text in between the quotes but instead prints all the remaining text after the first quote of the value parameter so like this: 26eca68705b3b0c76a6d0602937ac524" /><input type="hidden" id="md5pass" name="md5pass" value="1" /><input type="hidden" id="noerror" name="noerror" value="1" /><label><span>Email:</span><input type="text" class="inputtext" name="....MORE HTML SOURCE...

Any ideas as to why $1 seems to be capturing more that it should?

use strict; use CGI;

In reply to Regexp question by davidov0009

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.