What I'd like to do is redefine what "\b" is.
You can, by overloading regular expressions. The following is just a quick hack I threw together, but I think it catches most cases, including /[\b]/ and /\\b/.
#!/usr/bin/perl use strict; use warnings; no warnings qw /syntax/; BEGIN { my $B = '(?:(?<=[\w/])(?=[^\w/])|' . '(?<=[^\w/])(?=[\w/])|' . '^(?=[\w/])|(?<=[\w/])$)'; $^H |= 0x30000; $^H {qr} = sub { local $_ = $_ [1]; s/(\[\^?]?[^]]*]|[^\\]+|\\.)/$1 eq '\b' ? $B : $1/eg; $_; } } while (<DATA>) { chomp; print "$_: "; print $& if /\b\w+\b/; print "\n"; } __DATA__ foo &foo& &foo/bar& foo: foo &foo&: foo &foo/bar&:
Abigail
In reply to Re: Re-define Word Boundary?
by Abigail-II
in thread Re-define Word Boundary?
by JimJ
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |