const regex = /^2$/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('^2$', 'gm')
const 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)
`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
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 JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions