use strict;
my $str = 'Apr 17 08:09:45 clap ossec: Alert Level: 7; Rule: 550 - Integrity checksum changed.; Location: clap->syscheck; classification: ossec,syscheck,; Previous MD5: \'0a79ed913a931af0220c0349353ab9ec\'; Current MD5: \'809a2abe99e979b90e9298d3a052a312\'; Previous SHA1: \'814125fb17df21b9a91f8b1f839dac91733f0150\'; Current SHA1: \'3728e27f1f9ab27654ebb72aa6d01219d8624881\'; Size changed: from \'5780\' to \'5950\'; Integrity checksum changed for: \'/home/clapuser/UserDisable/disable.py\'';
my $regex = qr/changed\sfor:\s'+(?<changed_filename>\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