mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
Fixed global matching for simple strings in 'Find / Replace' operation. Closes #25.
This commit is contained in:
parent
3faef2c9c9
commit
04aac03d6e
3 changed files with 24 additions and 6 deletions
|
@ -259,6 +259,22 @@ const Utils = {
|
|||
},
|
||||
|
||||
|
||||
/**
|
||||
* Escape a string containing regex control characters so that it can be safely
|
||||
* used in a regex without causing unintended behaviours.
|
||||
*
|
||||
* @param {string} str
|
||||
* @returns {string}
|
||||
*
|
||||
* @example
|
||||
* // returns "\[example\]"
|
||||
* Utils.escapeRegex("[example]");
|
||||
*/
|
||||
escapeRegex: function(str) {
|
||||
return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Expand an alphabet range string into a list of the characters in that range.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue