use strict;
my $str = '- *Financial:* <yes or no. If yes, explain why>
- *Legal/Regulatory:* <yes or no. If yes, explain why>
- *Data Integrity:* <yes or no. If yes, explain why>
- *Patient Safety:* <yes or no. If yes, explain why>
- *CyberSecurity/Information Security:* <yes or no. If yes, explain why>
- *Financial:* <yes/no>
- *Legal/Regulatory:* <yes/no>
- *Data Integrity:* <yes/no>
- *Patient Safety:* <yes/no>
- *CyberSecurity/Information Security:* <yes/no>
- *Financial:* <yes or no. If yes, explain why>No
- *Legal/Regulatory:* <yes or no. If yes, explain why> Yes
- *Data Integrity:* No
- *Patient Safety:* Yes, this was an issue because of XYZ.
- *CyberSecurity/Information Security:* <yes or no. If yes, explain why>
- *Financial:* no
- *Legal/Regulatory:* no
- *Data Integrity:* no
- *Patient Safety:* no
- *CyberSecurity/Information Security:* no
- *Financial:* N
- *Legal/Regulatory:* N
- *Data Integrity:* N
- *Patient Safety:* N
- *CyberSecurity/Information Security:* N
- *Financial:* <yes or no. If yes, explain why>N
- *Legal/Regulatory:* <yes or no. If yes, explain why> N
- *Data Integrity:* <yes or no. If yes, explain why>N
- *Patient Safety:* <yes or no. If yes, explain why>N
- *CyberSecurity/Information Security:* <yes or no. If yes, explain why> N
';
my $regex = qr/\-\s\*data\sintegrity\:\*/ip;
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