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 it does match
<Connector port="PORT" protocol="AJP/1.3" redirectPort="PORT" />
And what would I need to do to match both with the same regex?
The
-n
option reads the file line-by-line, but you can alter what a line is to be the whole file by undefining the input line terminator. That's is done usinglocal $/;
, or using the command line option-0777
as follows:It reads in the whole file at once. If that's a problem, try setting
$/
to>
(since your pattern always ends in>
) or-o076
on the command-line: