mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-10 16:25:01 -04:00
Delete ExtractDates.mjs
This commit is contained in:
parent
05e65a74ce
commit
4b7b24d543
1 changed files with 0 additions and 52 deletions
|
@ -1,52 +0,0 @@
|
||||||
/**
|
|
||||||
* @author n1474335 [n1474335@gmail.com]
|
|
||||||
* @copyright Crown Copyright 2016
|
|
||||||
* @license Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
import Operation from "../Operation.mjs";
|
|
||||||
import { search } from "../lib/Extract.mjs";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extract dates operation
|
|
||||||
*/
|
|
||||||
class ExtractDates extends Operation {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ExtractDates constructor
|
|
||||||
*/
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
|
|
||||||
this.name = "Extract dates";
|
|
||||||
this.module = "Regex";
|
|
||||||
this.description = "Extracts dates in the following formats<ul><li><code>yyyy-mm-dd</code></li><li><code>dd/mm/yyyy</code></li><li><code>mm/dd/yyyy</code></li></ul>Dividers can be any of /, -, . or space";
|
|
||||||
this.inputType = "string";
|
|
||||||
this.outputType = "string";
|
|
||||||
this.args = [
|
|
||||||
{
|
|
||||||
"name": "Display total",
|
|
||||||
"type": "boolean",
|
|
||||||
"value": false
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} input
|
|
||||||
* @param {Object[]} args
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
run(input, args) {
|
|
||||||
const displayTotal = args[0],
|
|
||||||
date1 = "(?:19|20)\\d\\d[- /.](?:0[1-9]|1[012])[- /.](?:0[1-9]|[12][0-9]|3[01])", // yyyy-mm-dd
|
|
||||||
date2 = "(?:0[1-9]|[12][0-9]|3[01])[- /.](?:0[1-9]|1[012])[- /.](?:19|20)\\d\\d", // dd/mm/yyyy
|
|
||||||
date3 = "(?:0[1-9]|1[012])[- /.](?:0[1-9]|[12][0-9]|3[01])[- /.](?:19|20)\\d\\d", // mm/dd/yyyy
|
|
||||||
regex = new RegExp(date1 + "|" + date2 + "|" + date3, "ig");
|
|
||||||
|
|
||||||
return search(input, regex, null, displayTotal);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ExtractDates;
|
|
Loading…
Add table
Add a link
Reference in a new issue