string - Perl and Regex - single line mode matching -
why doesn't
perl -ne "print if /(<conn)([\s|\s]+?)(>)/sg;" /path/to/file match
<connector port="port" protocol="http/1.1" sslenabled="true" maxthreads="150" scheme="https" secure="true" clientauth="false" sslprotocol="tls" />` when match
<connector port="port" protocol="ajp/1.3" redirectport="port" /> and need match both same regex?
the -n option reads file line-by-line, can alter line whole file undefining input line terminator. that's done using local $/;, or using command line option -0777 follows:
perl -0777ne 'print "$1\n" while /(<conn.+?>)/sg;' /path/to/file it reads in whole file @ once. if that's problem, try setting $/ > (since pattern ends in >) or -o076 on command-line:
perl -076ne 'print "$1\n" if /(<conn.+?>)/sg;' /path/to/file
Comments
Post a Comment