in reply to Return value from positive look behind

Quibble: this is actually a lookahead, not a lookbehind. A lookbehind would be

m/(?<=\bare\s)(\d{1,2})/

Note that, depending on the version of Perl in use, variable-length lookbehinds (e.g. m/(?<=\bare\s{1,3})(\d{1,2})/ are either unavailable, or restricted in how much they can match.

Replies are listed 'Best First'.
Re^2: Return value from positive look behind (updated)
by AnomalousMonk (Archbishop) on Nov 12, 2020 at 16:15 UTC

    Variable-length positive lookbehinds of any length can be realized with the \K regex operator introduced with Perl version 5.10; see Lookaround Assertions in perlre. (Update: I should add that \K is mainly useful in s/// substitutions.)


    Give a man a fish:  <%-{-{-{-<