$ perl -e "use Path::Tiny; print path( q{ro/sham/bo} )->basename " $ perl -Mre=debug -e " $_ = q{ro/sham/bo} ; print m{/([^/]+?)$} " Compiling REx "/([^/]+?)$" Final program: 1: EXACT </> (3) 3: OPEN1 (5) 5: MINMOD (6) 6: PLUS (18) 7: ANYOF[\x00-.0-\xff][{unicode_all}] (0) 18: CLOSE1 (20) 20: EOL (21) 21: END (0) anchored "/" at 0 floating ""$ at 2..2147483647 (checking anchored) mi +nlen 2 Guessing start of match in sv for REx "/([^/]+?)$" against "ro/sham/bo +" Found anchored substr "/" at offset 2... Found floating substr ""$ at offset 10... Starting position does not contradict /^/m... Guessed: match at offset 2 Matching REx "/([^/]+?)$" against "/sham/bo" 2 <ro> </sham/bo> | 1:EXACT </>(3) 3 <ro/> <sham/bo> | 3:OPEN1(5) 3 <ro/> <sham/bo> | 5:MINMOD(6) 3 <ro/> <sham/bo> | 6:PLUS(18) ANYOF[\x00-.0-\xff][{unicode_all}] c +an match 1 times out of 1... 4 <ro/s> <ham/bo> | 18: CLOSE1(20) 4 <ro/s> <ham/bo> | 20: EOL(21) failed... ANYOF[\x00-.0-\xff][{unicode_all}] c +an match 1 times out of 1... 5 <ro/sh> <am/bo> | 18: CLOSE1(20) 5 <ro/sh> <am/bo> | 20: EOL(21) failed... ANYOF[\x00-.0-\xff][{unicode_all}] c +an match 1 times out of 1... 6 <ro/sha> <m/bo> | 18: CLOSE1(20) 6 <ro/sha> <m/bo> | 20: EOL(21) failed... ANYOF[\x00-.0-\xff][{unicode_all}] c +an match 1 times out of 1... 7 <ro/sham> </bo> | 18: CLOSE1(20) 7 <ro/sham> </bo> | 20: EOL(21) failed... ANYOF[\x00-.0-\xff][{unicode_all}] c +an match 0 times out of 1... failed... 7 <ro/sham> </bo> | 1:EXACT </>(3) 8 <ro/sham/> <bo> | 3:OPEN1(5) 8 <ro/sham/> <bo> | 5:MINMOD(6) 8 <ro/sham/> <bo> | 6:PLUS(18) ANYOF[\x00-.0-\xff][{unicode_all}] c +an match 1 times out of 1... 9 <ro/sham/b> <o> | 18: CLOSE1(20) 9 <ro/sham/b> <o> | 20: EOL(21) failed... ANYOF[\x00-.0-\xff][{unicode_all}] c +an match 1 times out of 1... 10 <ro/sham/bo> <> | 18: CLOSE1(20) 10 <ro/sham/bo> <> | 20: EOL(21) 10 <ro/sham/bo> <> | 21: END(0) Match successful! boFreeing REx: "/([^/]+?)$" $

In reply to Re: help with lazy matching by Anonymous Monk
in thread help with lazy matching by Special_K

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.