I'm interested in changing the regex word boundary \b to include other characters (for example, a . wouldn't count as a boundary). I understand that it is a boundary between \w and \W characters.
my $_ = ".test";
if ( /(\btest\b)/ ){
print;
print " $1\n";
}
if ( /((?:(?<=\W)|^)test(?:(?=\W)|$))/ ){
print;
print " $1\n";
}
This is what I came up with, and all I'd have to do is change \W to something like [^\w.], but I still want to know how Perl interprets \b in a regular expression. I tried deparsing it like this:
my $deparser = B::Deparse->new("-sC", "-x10");
print $deparser->coderef2text( sub {
my $_ = ".test";
if ( /(\btest\b)/ ){
print;
print " $1\n";
}
if ( /((?:(?<=\W)|^)test(?:(?=\W)|$))/ ){
print;
print " $1\n";
}
});
I was hoping it would expand \b into what it was equivalent to. What is \b equivalent to? Can you deparse \b or other expressions further somehow?