const regex = /<FilesMatch \"\(\^\\\.ht\|~\$\|\\\.bak\$\|\\\.BAK\$\|\\\.old\$\)\">(.*\n){1,}Order Allow,Deny Deny from all(.*\n){1,}<\/FilesMatch>(.*\n){1,}<DirectoryMatch \"\(\/CVS\/\|\.svn\)\">(.*\n){1,}Order Allow,Deny Deny from all(.*\n){1,}<\/DirectoryMatch>/;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('<FilesMatch \\"\\(\\^\\\\\\.ht\\|~\\$\\|\\\\\\.bak\\$\\|\\\\\\.BAK\\$\\|\\\\\\.old\\$\\)\\">(.*\\n){1,}Order Allow,Deny Deny from all(.*\\n){1,}<\\\/FilesMatch>(.*\\n){1,}<DirectoryMatch \\"\\(\\\/CVS\\\/\\|\\.svn\\)\\">(.*\\n){1,}Order Allow,Deny Deny from all(.*\\n){1,}<\\\/DirectoryMatch>', '')
const str = `<FilesMatch "(^\\.ht|~\$|\\.bak\$|\\.BAK\$|\\.old\$)">
Order Allow,Deny Deny from all
</FilesMatch>
<DirectoryMatch "(/CVS/|.svn)">
Order Allow,Deny Deny from all
</DirectoryMatch>`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
if ((m = regex.exec(str)) !== null) {
// 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