use strict;
my $str = 'add lb vserver VS_ssl_443_testapps SSL 0.0.0.0 0 -persistenceType RULE -timeout 30 -rule "HTTP.REQ.COOKIE.VALUE(\\"JSESSIONID\\")" -resRule "HTTP.RES.SET_COOKIE.COOKIE(\\"JSESSIONID\\").VALUE(\\"JSESSIONID\\")" -cltTimeout 600 -td 1
add lb vserver VS_ssl_8443_pega.awc_prd SSL 0.0.0.0 0 -persistenceType RULE -timeout 30 -rule "HTTP.REQ.COOKIE.VALUE(\\"jsessionid\\") ALT HTTP.REQ.URL.BEFORE_STR(\\"?\\").AFTER_STR(\\";jsessionid=\\") ALT HTTP.REQ.URL.AFTER_STR(\\";jsessionid=\\")" -resRul';
my $regex = qr/-rule\s*(\"(\\\"|[^\"])*\")/mp;
if ( $str =~ /$regex/g ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html