|
@@ -6,6 +6,7 @@
|
|
|
|
|
|
import Operation from "../Operation";
|
|
import Operation from "../Operation";
|
|
import Dish from "../Dish";
|
|
import Dish from "../Dish";
|
|
|
|
+import XRegExp from "xregexp";
|
|
|
|
|
|
/**
|
|
/**
|
|
* Register operation
|
|
* Register operation
|
|
@@ -20,7 +21,7 @@ class Register extends Operation {
|
|
|
|
|
|
this.name = "Register";
|
|
this.name = "Register";
|
|
this.flowControl = true;
|
|
this.flowControl = true;
|
|
- this.module = "Default";
|
|
|
|
|
|
+ this.module = "Regex";
|
|
this.description = "Extract data from the input and store it in registers which can then be passed into subsequent operations as arguments. Regular expression capture groups are used to select the data to extract.<br><br>To use registers in arguments, refer to them using the notation <code>$Rn</code> where n is the register number, starting at 0.<br><br>For example:<br>Input: <code>Test</code><br>Extractor: <code>(.*)</code><br>Argument: <code>$R0</code> becomes <code>Test</code><br><br>Registers can be escaped in arguments using a backslash. e.g. <code>\\$R0</code> would become <code>$R0</code> rather than <code>Test</code>.";
|
|
this.description = "Extract data from the input and store it in registers which can then be passed into subsequent operations as arguments. Regular expression capture groups are used to select the data to extract.<br><br>To use registers in arguments, refer to them using the notation <code>$Rn</code> where n is the register number, starting at 0.<br><br>For example:<br>Input: <code>Test</code><br>Extractor: <code>(.*)</code><br>Argument: <code>$R0</code> becomes <code>Test</code><br><br>Registers can be escaped in arguments using a backslash. e.g. <code>\\$R0</code> would become <code>$R0</code> rather than <code>Test</code>.";
|
|
this.infoURL = "https://wikipedia.org/wiki/Regular_expression#Syntax";
|
|
this.infoURL = "https://wikipedia.org/wiki/Regular_expression#Syntax";
|
|
this.inputType = "string";
|
|
this.inputType = "string";
|
|
@@ -40,6 +41,11 @@ class Register extends Operation {
|
|
"name": "Multiline matching",
|
|
"name": "Multiline matching",
|
|
"type": "boolean",
|
|
"type": "boolean",
|
|
"value": false
|
|
"value": false
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "name": "Dot matches all",
|
|
|
|
+ "type": "boolean",
|
|
|
|
+ "value": false
|
|
}
|
|
}
|
|
];
|
|
];
|
|
}
|
|
}
|
|
@@ -53,13 +59,14 @@ class Register extends Operation {
|
|
*/
|
|
*/
|
|
async run(state) {
|
|
async run(state) {
|
|
const ings = state.opList[state.progress].ingValues;
|
|
const ings = state.opList[state.progress].ingValues;
|
|
- const [extractorStr, i, m] = ings;
|
|
|
|
|
|
+ const [extractorStr, i, m, s] = ings;
|
|
|
|
|
|
let modifiers = "";
|
|
let modifiers = "";
|
|
if (i) modifiers += "i";
|
|
if (i) modifiers += "i";
|
|
if (m) modifiers += "m";
|
|
if (m) modifiers += "m";
|
|
|
|
+ if (s) modifiers += "s";
|
|
|
|
|
|
- const extractor = new RegExp(extractorStr, modifiers),
|
|
|
|
|
|
+ const extractor = new XRegExp(extractorStr, modifiers),
|
|
input = await state.dish.get(Dish.STRING),
|
|
input = await state.dish.get(Dish.STRING),
|
|
registers = input.match(extractor);
|
|
registers = input.match(extractor);
|
|
|
|
|