use strict;
my $str = '1. What is being changed?
Add in Solarwinds monitoring the router and switch of the new Store:
Devices - MCHLS5178,sw517801,sr517800,sr517801,sr517802,MCHLS5184,sw518401,sr518400,sr518401,sr518402
Community String - N/A
2. Where it is being changed?
Solarwinds monitoring (10.3.4.7)
3. Why it is being changed?
To monitor the router and switch of the store 5178,5184
4. What is the Business Impact of the Change?
No business impact during implementation.
5. Who will be doing the change?
Network team
6. When is the change happening?
2020-01-26 01:00:00
7. Who will be testing the change after implementation?
Network team';
my $regex = qr/(?i)\b(Devices|Community String)\b\s*-\s*([\w,\/]+)/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