ToCaseInsensitiveRegex improvements

This commit is contained in:
n1073645 2019-11-18 13:31:19 +00:00
parent 02ec4a3bfd
commit 40d3c8b071

View file

@ -54,31 +54,31 @@ class ToCaseInsensitiveRegex extends Operation {
// Example: [a-z] -> [a-zA-Z] // Example: [a-z] -> [a-zA-Z]
input = input.replace(/[a-z]-[a-z]/g, m => `${m}${m[0].toUpperCase()}-${m[2].toUpperCase()}`); input = input.replace(/[a-z]-[a-z]/g, m => `${m}${m[0].toUpperCase()}-${m[2].toUpperCase()}`);
// Example: [a-z] -> [a-zA-Z] // Example: [a-z] -> [a-zA-Z]
input = input.replace(/[A-Z]-[A-Z]/g, m => `${m}${m[0].toLowerCase()}-${m[2].toLowerCase()}`); input = input.replace(/[A-Z]-[A-Z]/g, m => `${m}${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`); input = input.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()}`); input = input.replace(/[ -@]-[A-Z]/g, m => `${m}a-${m[2].toLowerCase()}`);
// Example: [%-^] -> [%-^a-z] // Example: [%-^] -> [%-^a-z]
input = input.replace(/[ -@]-[[-`]/g, m => `${m}a-z`); input = input.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`); input = input.replace(/[A-Z]-[[-`]/g, m => `${m}${m[0].toLowerCase()}-z`);
// Example: [[-}] -> [[-}A-Z] // Example: [[-}] -> [[-}A-Z]
input = input.replace(/[[-`]-[{-~]/g, m => `${m}A-Z`); input = input.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`); input = input.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`); input = input.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}`); input = input.replace(/[[-`]-[a-z]/g, m => `A-${m[2].toUpperCase()}${m}`);
return input; return input;