The space matched in the former [[:alpha:] ], and can't matched in the last \s+Age:。So I think the text can't matched the reg pattern. Because there is only one space between name and age.

Hmm, if perl matches it, why do you think that is?

If you turn on use re 'debug' ; what do you see?

I see

149 <Princ> <e Age: 53> | 21: CLOSE1(23) 149 <Princ> <e Age: 53> | 23: PLUS(25) SPACE can match 0 times out of 2 +147483647... failed... ANYOF[ A-Za-z][{unicode}+utf8::XPo +sixAlpha 00AA 00B5 00BA 00C0-00D6 00D8-00F6 00F8- 02C1] can match 1 times out of 1... 150 <rince> < Age: 53%n> | 21: CLOSE1(23) 150 <rince> < Age: 53%n> | 23: PLUS(25) SPACE can match 1 times out of 2 +147483647... 151 <ince > <Age: 53%nO> | 25: EXACT <Age:>(27) 155 < Age:> < 53%nOccup> | 27: PLUS(29) SPACE can match 1 times out of + 2147483647...

+? means match the least amount possible, the least amount doesn't include space, because the next pattern wants space


In reply to Re^3: a regex pattern how to understand by Anonymous Monk
in thread a regex pattern how to understand by Thai Heng

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.