- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2023 12:05 AM
Hi,
Im getting two strings in my log:
1) '22122b37c611228400f9ff91c857581d]'
2) '[aaccc971c0a8001500fe1ff4302de101'
how can I replace the special character '[' and ']' in each case. Im trying to use:
sys_id = str.replace([, '');
sys_id = str.replace(], '');
but its not working
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2023 12:15 AM - edited 01-18-2023 12:17 AM
Hi,
For me, validated in script background:
sys_id = str.replace(/[\[\]]/, '');
var str1 = '22122b37c611228400f9ff91c857581d]';
var str2 = '[aaccc971c0a8001500fe1ff4302de101';
var newStr;
newStr = str1.replace(/[\[\]]/, '');
gs.info(newStr);
newStr = str2.replace(/[\[\]]/, '');
gs.info(newStr);
hth,matt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2023 12:15 AM - edited 01-18-2023 12:17 AM
Hi,
For me, validated in script background:
sys_id = str.replace(/[\[\]]/, '');
var str1 = '22122b37c611228400f9ff91c857581d]';
var str2 = '[aaccc971c0a8001500fe1ff4302de101';
var newStr;
newStr = str1.replace(/[\[\]]/, '');
gs.info(newStr);
newStr = str2.replace(/[\[\]]/, '');
gs.info(newStr);
hth,matt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2023 02:10 AM
Hi,
I now realise my answer may have been something of a partial solution, in that it will only replace one instance of the characters specified, to remove multiple instances of ][ from a string I believe this global replace may be more appropriate:
sys_id = str.replace(/[\[\]]/g, '');
hth,matt