Hi All, I have a regular expression in place that does a check on a string coming in from a form. The regular expression is as such : $string =~ m/^(frm)(\w+)(txt)?$/; What I was hoping to accomplish was to have $1, $2, and $3 populated with the values in the brackets. When I run this and the string is something like frmNametxt the $1 gets set to frm, $2 gets set to Nametxt and $3 to nothing. What (if anything) can I do to force the code to evaluate and store txt into $3? If txt is there I want it put into $3. Any help would be most appreciated. Thanks. Rob

In reply to RegExp Matched Values by rpike

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.