CyberChef/src/core/operations/RemoveLineNumbers.mjs

47 lines
1,022 B
JavaScript
Raw Normal View History

2018-05-14 16:46:54 +00:00
/**
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2016
* @license Apache-2.0
*/
import Operation from "../Operation.mjs";
2018-05-14 16:46:54 +00:00
/**
* Remove line numbers operation
*/
class RemoveLineNumbers extends Operation {
/**
* RemoveLineNumbers constructor
*/
constructor() {
super();
this.name = "Remove line numbers";
this.module = "Default";
this.description = "Removes line numbers from the output if they can be trivially detected.";
this.inputType = "string";
this.outputType = "string";
this.args = [];
2019-11-26 16:43:54 +00:00
this.patterns = [
{
2019-11-27 10:24:31 +00:00
match: "^\\s*([0-9]+ .*?(\\n))+[0-9] .+$",
2019-11-26 16:43:54 +00:00
flags: "",
args: []
}
];
2018-05-14 16:46:54 +00:00
}
/**
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
return input.replace(/^[ \t]{0,5}\d+[\s:|\-,.)\]]/gm, "");
}
}
export default RemoveLineNumbers;