Problems? Is your data what you think it is? | |
PerlMonks |
Re: Question about regex.by GrandFather (Saint) |
on Sep 29, 2020 at 03:07 UTC ( [id://11122315]=note: print w/replies, xml ) | Need Help?? |
NetWalla identified your immediate problem, but there is an issue with your regex. The spaces around third and four are required to match spaces in the string you are matching against. On top of that, you don't prevent matching words that contain third or four (fourth for example). You can fix both issues like this:
Prints:
the \b matches word boundaries.
Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
In Section
Seekers of Perl Wisdom
|
|