use YAPE::Regex::Explain;
print YAPE::Regex::Explain->new("A\\B")->explain;
__END__
The regular expression:
(?-imsx:A\B)
matches as follows:
NODE EXPLANATION
----------------------------------------------------------------------
(?-imsx: group, but do not capture (case-sensitive)
(with ^ and $ matching normally) (with . not
matching \n) (matching whitespace and #
normally):
----------------------------------------------------------------------
A 'A'
----------------------------------------------------------------------
\B the boundary between two word chars (\w)
or two non-word chars (\W)
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------
use YAPE::Regex::Explain;
print YAPE::Regex::Explain->new("\\B")->explain;
__END__
The regular expression:
(?-imsx:\B)
matches as follows:
NODE EXPLANATION
----------------------------------------------------------------------
(?-imsx: group, but do not capture (case-sensitive)
(with ^ and $ matching normally) (with . not
matching \n) (matching whitespace and #
normally):
----------------------------------------------------------------------
\B the boundary between two word chars (\w)
or two non-word chars (\W)
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------
use re 'debug';
$x = "A\\B";
$y = "Here is A\\B";
print $y =~ /$x/ ? "y" : "n";
__END__
Compiling REx `A\B'
size 4 Got 36 bytes for offset annotations.
first at 1
1: EXACT <A>(3)
3: NBOUND(4)
4: END(0)
anchored "A" at 0 (checking anchored) minlen 1
Offsets: [4]
1[1] 0[0] 2[2] 4[0]
Guessing start of match, REx "A\B" against "Here is A\B"...
Found anchored substr "A" at offset 8...
Starting position does not contradict /^/m...
Guessed: match at offset 8
Matching REx "A\B" against "A\B"
Setting an EVAL scope, savestack=3
8 <Here is > <A\B> | 1: EXACT <A>
9 <Here is A> <\B> | 3: NBOUND
failed...
Match failed
nFreeing REx: `"A\\B"'
use re 'debug';
$x = "\\B";
$y = "Here is \\B";
print $y =~ /$x/ ? "y" : "n";
__END__
Compiling REx `\B'
size 2 Got 20 bytes for offset annotations.
first at 1
1: NBOUND(2)
2: END(0)
stclass "NBOUND" minlen 0
Offsets: [2]
1[2] 3[0]
Matching REx "\B" against "Here is \B"
Matching stclass "NBOUND" against "Here is \B"
Setting an EVAL scope, savestack=3
1 <H> <ere is \B> | 1: NBOUND
1 <H> <ere is \B> | 2: END
Match successful!
yFreeing REx: `"\\B"'
|