use strict;
my $str = '# ___ ___ ___ ___ ___
# | _ )_ ) __| / __| __ _ _ ___ ___ _ _ | _ \\___ ___
# | _ \\/ /\\__ \\ \\__ \\/ _| \'_/ -_) -_) \' \\| / -_|_-<
# |___/___|___/__|___/\\__|_| \\___\\___|_||_|_|_\\___/__/
# |_ _| __| \\/ | _ \\ | /_\\_ _| __|
# | | | _|| |\\/| | _/ |__ / _ \\| | | _|
# |_| |___|_| |_|_| |____/_/ \\_\\_| |___|
#
# PLEASE MODIFY FOR YOUR OWN USAGE
# Playfield Screen resolution width/height
1920
1080
# Backglass Screen resolution width/height
1280
1024
# Define Backglass using Display Devicename screen number (\\\\.\\DISPLAY)x or screen coordinates (@x) or screen index (=x)
2
# x position For the backglass relative To the upper left corner Of the Playfield screen
0
# y position For the backglass On the selected display (Normally left at 0)
0
# width/height Of the DMD area In pixels - For 3 screen setup
551
189
# X/Y position Of the DMD area relative To the upper left corner Of the backglass screen - For 3 screen setup
367
813
# Y-flip, flips the LED display upside down
0
# X/Y position pos When StartBackground Is active, relative To upper left corner Of Playfield (\'Small\' Button In the Options)
0
0
# width/height Of the backglass When StartBackground Is active
0
0
# C:\\path\\Frame (The path To the location where you have the background image)
';
my $regex = qr/^2$/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