|
@@ -6,6 +6,7 @@
|
|
|
|
|
|
import Operation from "../Operation";
|
|
|
import Utils from "../Utils";
|
|
|
+import XRegExp from "xregexp";
|
|
|
|
|
|
/**
|
|
|
* Find / Replace operation
|
|
@@ -50,6 +51,11 @@ class FindReplace extends Operation {
|
|
|
"name": "Multiline matching",
|
|
|
"type": "boolean",
|
|
|
"value": true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "name": "Dot matches all",
|
|
|
+ "type": "boolean",
|
|
|
+ "value": false
|
|
|
}
|
|
|
];
|
|
|
}
|
|
@@ -60,16 +66,17 @@ class FindReplace extends Operation {
|
|
|
* @returns {string}
|
|
|
*/
|
|
|
run(input, args) {
|
|
|
- const [{option: type}, replace, g, i, m] = args;
|
|
|
+ const [{option: type}, replace, g, i, m, s] = args;
|
|
|
let find = args[0].string,
|
|
|
modifiers = "";
|
|
|
|
|
|
if (g) modifiers += "g";
|
|
|
if (i) modifiers += "i";
|
|
|
if (m) modifiers += "m";
|
|
|
+ if (s) modifiers += "s";
|
|
|
|
|
|
if (type === "Regex") {
|
|
|
- find = new RegExp(find, modifiers);
|
|
|
+ find = new XRegExp(find, modifiers);
|
|
|
return input.replace(find, replace);
|
|
|
}
|
|
|
|
|
@@ -77,7 +84,7 @@ class FindReplace extends Operation {
|
|
|
find = Utils.parseEscapedChars(find);
|
|
|
}
|
|
|
|
|
|
- find = new RegExp(Utils.escapeRegex(find), modifiers);
|
|
|
+ find = new XRegExp(Utils.escapeRegex(find), modifiers);
|
|
|
|
|
|
return input.replace(find, replace);
|
|
|
}
|