Trying to replace a string that contains special characters. The purpose of this is to convert the query string into an understandable format for end users.
full string is:
var str = 'active=true^opened_by=6816f79cc0a8016401c5a33be04be441^ORassigned_to!=6816f79cc0a8016401c5a33be04be441^short_descriptionISNOTEMPTY^NQopened_atONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()^EQ';
Specifically the portion after ^NQ
, in this example: opened_atONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()
. I have split the original string with indexOf(^NQ)
and passing the resulting sub-strings to a function. I'm then trying a .replace()
as below:
var today = replacementString.replace(/(ONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday())/g, ' is today ');
replacementString = today;
I have tried with various combinations of the above line, but have not returned what I am hoping for.
I've had no issues replacing special characters, or strings without special characters, but the combination of the 2 is confusing/frustrating me.
Any suggestions or guidance would be appreciated