in reply to seeking expression to match "/mysearch/detail/966031"

You must escape / in regexes:
perl -e "print $1 if $ARGV[0]=~/(\/newsearch\/detail\/96603)/" "bla vl +a/newsearch/detail/96603 x" /newsearch/detail/96603

You can also choose a different delimiter instead of / see perlrequick for details and this way you prevent the leaning toothpick syndrome

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: seeking expression to match "/mysearch/detail/966031"
by AnomalousMonk (Archbishop) on Nov 18, 2016 at 19:16 UTC
    You must escape / in regexes ...

    A literal delimiter character in a regex like  /...\/.../ must be escaped, but if the delimiter is within an interpolated string (as in the OPed regex), the regex compiler is quite happy with it:

    c:\@Work\Perl>perl -wMstrict -le "my $re = '.../...'; ;; print 'match' if 'xxx/xxx' =~ /$re/; " match


    Give a man a fish:  <%-{-{-{-<