Small confusion in regex at | (pipe) -
when use pattren
"(see|see also) [\w\d]+"
on text
see page see page
but output matches is
see page see
if im interchanged see, see also
"(see also|see) [\w\d]+"
the output
see page see page
i thought both same. may know why happen?
removing alternation , leaving see [\w\d]+
match string "see page" because satisfied see also
. way regular expressions work alternation (at least in case) attempt match each option in order rest of pattern , stop successfully, or go alternatives when fails. when reverse alternation, tries match see also
first, fail "see page."
it make more sense write see( also)? [\w\d]+
Comments
Post a Comment