mirror of
https://github.com/gchq/CyberChef.git
synced 2024-11-02 14:11:02 +01:00
Replaced the .replaces in regex operation
This commit is contained in:
parent
6d77fe6eb3
commit
7d41d4d030
@ -51,36 +51,35 @@ class ToCaseInsensitiveRegex extends Operation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Example: [test] -> [[tT][eE][sS][tT]]
|
// Example: [test] -> [[tT][eE][sS][tT]]
|
||||||
input = preProcess(input);
|
return preProcess(input)
|
||||||
|
|
||||||
// Example: [A-Z] -> [A-Za-z]
|
// Example: [A-Z] -> [A-Za-z]
|
||||||
input = input.replace(/[A-Z]-[A-Z]/ig, m => `${m[0].toUpperCase()}-${m[2].toUpperCase()}${m[0].toLowerCase()}-${m[2].toLowerCase()}`);
|
.replace(/[A-Z]-[A-Z]/ig, m => `${m[0].toUpperCase()}-${m[2].toUpperCase()}${m[0].toLowerCase()}-${m[2].toLowerCase()}`)
|
||||||
|
|
||||||
// Example: [H-d] -> [A-DH-dh-z]
|
// Example: [H-d] -> [A-DH-dh-z]
|
||||||
input = input.replace(/[A-Z]-[a-z]/g, m => `A-${m[2].toUpperCase()}${m}${m[0].toLowerCase()}-z`);
|
.replace(/[A-Z]-[a-z]/g, m => `A-${m[2].toUpperCase()}${m}${m[0].toLowerCase()}-z`)
|
||||||
|
|
||||||
// Example: [!-D] -> [!-Da-d]
|
// Example: [!-D] -> [!-Da-d]
|
||||||
input = input.replace(/\\?[ -@]-[A-Z]/g, m => `${m}a-${m[2].toLowerCase()}`);
|
.replace(/\\?[ -@]-[A-Z]/g, m => `${m}a-${m[2].toLowerCase()}`)
|
||||||
|
|
||||||
// Example: [%-^] -> [%-^a-z]
|
// Example: [%-^] -> [%-^a-z]
|
||||||
input = input.replace(/\\?[ -@]-\\?[[-`]/g, m => `${m}a-z`);
|
.replace(/\\?[ -@]-\\?[[-`]/g, m => `${m}a-z`)
|
||||||
|
|
||||||
// Example: [K-`] -> [K-`k-z]
|
// Example: [K-`] -> [K-`k-z]
|
||||||
input = input.replace(/[A-Z]-\\?[[-`]/g, m => `${m}${m[0].toLowerCase()}-z`);
|
.replace(/[A-Z]-\\?[[-`]/g, m => `${m}${m[0].toLowerCase()}-z`)
|
||||||
|
|
||||||
// Example: [[-}] -> [[-}A-Z]
|
// Example: [[-}] -> [[-}A-Z]
|
||||||
input = input.replace(/\\?[[-`]-\\?[{-~]/g, m => `${m}A-Z`);
|
.replace(/\\?[[-`]-\\?[{-~]/g, m => `${m}A-Z`)
|
||||||
|
|
||||||
// Example: [b-}] -> [b-}B-Z]
|
// Example: [b-}] -> [b-}B-Z]
|
||||||
input = input.replace(/[a-z]-\\?[{-~]/g, m => `${m}${m[0].toUpperCase()}-Z`);
|
.replace(/[a-z]-\\?[{-~]/g, m => `${m}${m[0].toUpperCase()}-Z`)
|
||||||
|
|
||||||
// Example: [<-j] -> [<-z]
|
// Example: [<-j] -> [<-z]
|
||||||
input = input.replace(/\\?[ -@]-[a-z]/g, m => `${m[0]}-z`);
|
.replace(/\\?[ -@]-[a-z]/g, m => `${m[0]}-z`)
|
||||||
|
|
||||||
// Example: [^-j] -> [A-J^-j]
|
// Example: [^-j] -> [A-J^-j]
|
||||||
input = input.replace(/\\?[[-`]-[a-z]/g, m => `A-${m[2].toUpperCase()}${m}`);
|
.replace(/\\?[[-`]-[a-z]/g, m => `A-${m[2].toUpperCase()}${m}`);
|
||||||
|
|
||||||
return input;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user