mirror of
https://github.com/gchq/CyberChef.git
synced 2024-11-16 08:58:30 +01:00
39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
/**
|
|
* @author masq [github.cyberchef@masq.cc]
|
|
* @copyright Crown Copyright 2018
|
|
* @license Apache-2.0
|
|
*/
|
|
|
|
import Operation from "../Operation.mjs";
|
|
|
|
/**
|
|
* From Case Insensitive Regex operation
|
|
*/
|
|
class FromCaseInsensitiveRegex extends Operation {
|
|
|
|
/**
|
|
* FromCaseInsensitiveRegex constructor
|
|
*/
|
|
constructor() {
|
|
super();
|
|
|
|
this.name = "From Case Insensitive Regex";
|
|
this.module = "Default";
|
|
this.description = "Converts a case-insensitive regex string to a case sensitive regex string (no guarantee on it being the proper original casing) in case the i flag wasn't available at the time but now is, or you need it to be case-sensitive again.<br><br>e.g. <code>[mM][oO][zZ][iI][lL][lL][aA]/[0-9].[0-9] .*</code> becomes <code>Mozilla/[0-9].[0-9] .*</code>";
|
|
this.infoURL = "https://wikipedia.org/wiki/Regular_expression";
|
|
this.inputType = "string";
|
|
this.outputType = "string";
|
|
this.args = [];
|
|
}
|
|
|
|
/**
|
|
* @param {string} input
|
|
* @param {Object[]} args
|
|
* @returns {string}
|
|
*/
|
|
run(input, args) {
|
|
return input.replace(/\[[a-z]{2}\]/ig, m => m[1].toUpperCase() === m[2].toUpperCase() ? m[1] : m);
|
|
}
|
|
}
|
|
|
|
export default FromCaseInsensitiveRegex;
|