in reply to Re^3: Return string that starts and ends with specific characters
in thread Return string that starts and ends with specific characters
... it also works with \b
... unless the string ends with the target character/pattern:
Personally, I feel more comfortable using something that cannot possibly be true to force backtracking, like (?!) or, from Perl 5.10 on, (*FAIL) or (*F) even though they take more keystrokes to type.c:\@Work\Perl\monks>perl -wMstrict -le "my @answer; 'asdfgfhjkljx' =~ /f.*j(?{push @answer, $&})\b/; print for @answer; " fgfhjklj fgfhj fhjklj fhj c:\@Work\Perl\monks>perl -wMstrict -le "my @answer; 'asdfgfhjklj' =~ /f.*j(?{push @answer, $&})\b/; print for @answer; " fgfhjklj
Update: Oops... I missed "... this special case (single word without a j at the end) ..." in Eily's post; see Eily's reply below.
Give a man a fish: <%-{-{-{-<
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Return string that starts and ends with specific characters
by Eily (Monsignor) on Jun 02, 2016 at 18:42 UTC |