mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-23 00:06:17 -04:00
Merge branch 'insense' of https://github.com/masq/CyberChef into masq-insense
This commit is contained in:
commit
c5270d75a1
5 changed files with 137 additions and 0 deletions
39
src/core/operations/FromCaseInsensitiveRegex.mjs
Normal file
39
src/core/operations/FromCaseInsensitiveRegex.mjs
Normal file
|
@ -0,0 +1,39 @@
|
|||
/**
|
||||
* @author masq [github.cyberchef@masq.cc]
|
||||
* @copyright Crown Copyright 2018
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation";
|
||||
|
||||
/**
|
||||
* 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 /i wasn't available at the time but now is, or you need it to be case-sensitive again.";
|
||||
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;
|
39
src/core/operations/ToCaseInsensitiveRegex.mjs
Normal file
39
src/core/operations/ToCaseInsensitiveRegex.mjs
Normal file
|
@ -0,0 +1,39 @@
|
|||
/**
|
||||
* @author masq [github.cyberchef@masq.cc]
|
||||
* @copyright Crown Copyright 2018
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation";
|
||||
|
||||
/**
|
||||
* To Case Insensitive Regex operation
|
||||
*/
|
||||
class ToCaseInsensitiveRegex extends Operation {
|
||||
|
||||
/**
|
||||
* ToCaseInsensitiveRegex constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "To Case Insensitive Regex";
|
||||
this.module = "Default";
|
||||
this.description = "Converts a case-sensitive regex string into a case-insensitive regex string in case /i flag is unavailable to you.";
|
||||
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]/ig, m => `[${m.toLowerCase()}${m.toUpperCase()}]`);
|
||||
}
|
||||
}
|
||||
|
||||
export default ToCaseInsensitiveRegex;
|
Loading…
Add table
Add a link
Reference in a new issue