mirror of
https://github.com/gchq/CyberChef
synced 2025-12-20 10:13:42 +00:00
'Find/Replace', 'Filter' and 'Register' now used XRegExp
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
import Operation from "../Operation";
|
||||
import Dish from "../Dish";
|
||||
import XRegExp from "xregexp";
|
||||
|
||||
/**
|
||||
* Register operation
|
||||
@@ -20,7 +21,7 @@ class Register extends Operation {
|
||||
|
||||
this.name = "Register";
|
||||
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.infoURL = "https://wikipedia.org/wiki/Regular_expression#Syntax";
|
||||
this.inputType = "string";
|
||||
@@ -40,6 +41,11 @@ class Register extends Operation {
|
||||
"name": "Multiline matching",
|
||||
"type": "boolean",
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"name": "Dot matches all",
|
||||
"type": "boolean",
|
||||
"value": false
|
||||
}
|
||||
];
|
||||
}
|
||||
@@ -53,13 +59,14 @@ class Register extends Operation {
|
||||
*/
|
||||
async run(state) {
|
||||
const ings = state.opList[state.progress].ingValues;
|
||||
const [extractorStr, i, m] = ings;
|
||||
const [extractorStr, i, m, s] = ings;
|
||||
|
||||
let modifiers = "";
|
||||
if (i) modifiers += "i";
|
||||
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),
|
||||
registers = input.match(extractor);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user