The basic problem stems from a too-liberal use of the (?:\b|_) assertion.
The $parse1 string begins with a / (forward slash) character. This is not a \w character. The (?:\b|_) assertions in (?:\b|_)$parse1(?:\b|_) require that $parse1 be preceded by a \w character or a _ (underscore) (note that _ is a member of the \w class), and followed by a non-\w character or a _ (underscore).
What the OPed regex will match depends on the string it is matching against. I would advise giving us examples of typical strings. Below are some examples of mine that show various matches/non-matches:
c:\@Work\Perl>perl -wMstrict -le "print qq{perl version: $] \n}; ;; my $parse1 = '/newsearch/detail/96603'; my $parse2 = ''; ;; for ( qq{xxx \n/newsearch/detail/96603\n xxx}, qq{xxx \n/newsearch/detail/96603x\n xxx}, qq{xxx \nx/newsearch/detail/96603x\n xxx}, qq{xxx \nx/newsearch/detail/96603\n xxx}, qq{bla vla/newsearch/detail/96603 x}, ) { print qq{<<$_>>}; print qq{MATCH '$&'} if /^.*?(?:\b|_)$parse1(?:\b|_).*?(?:\b|_)$parse2(?:\b|_).*?$/m; print ''; } " perl version: 5.008009 <<xxx /newsearch/detail/96603 xxx>> <<xxx /newsearch/detail/96603x xxx>> <<xxx x/newsearch/detail/96603x xxx>> <<xxx x/newsearch/detail/96603 xxx>> MATCH 'x/newsearch/detail/96603' <<bla vla/newsearch/detail/96603 x>> MATCH 'bla vla/newsearch/detail/96603 x'
Update: Because you give no examples of the typical strings you're matching against, I cannot understand the implications of the ^.*? and .*?$ and .*?(?:\b|_)$parse2(?:\b|_) portions of the OPed regex (which I suspect may be superfluous), or why you are matching in /m "multi-line" mode.
Give a man a fish: <%-{-{-{-<
In reply to Re: seeking expression to match "/mysearch/detail/966031"
by AnomalousMonk
in thread seeking expression to match "/mysearch/detail/966031"
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |