Keep It Simple, Stupid | |
PerlMonks |
Re: Re-define Word Boundary?by thelenm (Vicar) |
on Nov 20, 2003 at 23:27 UTC ( [id://308753]=note: print w/replies, xml ) | Need Help?? |
\w matches alphanumerics and underscore. \b is effectively the same as using lookbehinds and lookaheads like this:
Update: Hmm, or even nicer, as merlyn posted in •Re: Why do zero width assertions care about lookahead/behind? (code examples also updated),
So to make a specialized version of \b that views "-" and "/" as "word characters" (sort of), you might use something like this:
So maybe something like this will suit you?
I've tested this a little but not a lot, and it seems all right. You'll want to verify it yourself before you go using it for anything important :-) -- Mike --
In Section
Seekers of Perl Wisdom
|
|