Add use re 'debug'; or perl -Mre=debug myfile.pl and you can get output like
#!/usr/bin/perl -- use strict; use warnings; use re 'debug'; my $str = "Test*.Value"; print "$1 $2\n" if($str=~/(.*?)\*(.*?)/); __END__ Compiling REx `(.*?)\*(.*?)' size 17 Got 140 bytes for offset annotations. first at 4 synthetic stclass `ANYOF[\0-\11\13-\377{unicode_all}]'. 1: OPEN1(3) 3: MINMOD(4) 4: STAR(6) 5: REG_ANY(0) 6: CLOSE1(8) 8: EXACT <*>(10) 10: OPEN2(12) 12: MINMOD(13) 13: STAR(15) 14: REG_ANY(0) 15: CLOSE2(17) 17: END(0) floating `*' at 0..2147483647 (checking floating) stclass `ANYOF[\0-\1 +1\13-\377{unicode_all}]' minlen 1 Offsets: [17] 1[1] 0[0] 4[1] 3[1] 2[1] 5[1] 0[0] 6[2] 0[0] 8[1] 0[0] 11[1] 1 +0[1] 9[1] 12[1] 0[0] 13[0] Guessing start of match, REx `(.*?)\*(.*?)' against `Test*.Value'... Found floating substr `*' at offset 4... Does not contradict STCLASS... Guessed: match at offset 0 Matching REx `(.*?)\*(.*?)' against `Test*.Value' Matching stclass `ANYOF[\0-\11\13-\377{unicode_all}]' against `Test*.V +alue' Setting an EVAL scope, savestack=5 0 <> <Test*.Value> | 1: OPEN1 0 <> <Test*.Value> | 3: MINMOD 0 <> <Test*.Value> | 4: STAR Setting an EVAL scope, savestack=5 REG_ANY can match 4 times out of 4... 4 <Test> <*.Value> | 6: CLOSE1 4 <Test> <*.Value> | 8: EXACT <*> 5 <Test*> <.Value> | 10: OPEN2 5 <Test*> <.Value> | 12: MINMOD 5 <Test*> <.Value> | 13: STAR Setting an EVAL scope, savestack=5 5 <Test*> <.Value> | 15: CLOSE2 5 <Test*> <.Value> | 17: END Match successful! Test Freeing REx: `"(.*?)\\*(.*?)"'
Another helpful tool is YAPE::Regex::Explain
#!/usr/bin/perl -- use YAPE::Regex::Explain; print YAPE::Regex::Explain->new(qr/(.*?)\*(.*?)/)->explain,$/ __END__ The regular expression: (?-imsx:(.*?)\*(.*?)) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- ( group and capture to \1: ---------------------------------------------------------------------- .*? any character except \n (0 or more times (matching the least amount possible)) ---------------------------------------------------------------------- ) end of \1 ---------------------------------------------------------------------- \* '*' ---------------------------------------------------------------------- ( group and capture to \2: ---------------------------------------------------------------------- .*? any character except \n (0 or more times (matching the least amount possible)) ---------------------------------------------------------------------- ) end of \2 ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------

In reply to Re: regex question by Anonymous Monk
in thread regex question by Alien

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.