Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2021 01:35 PM
Hi,
I want to convert all the special characters into the underscores. Any snipped will be helpful
Thanks,
Sai
Solved! Go to Solution.
Labels:
- Labels:
-
Service Catalog
1 ACCEPTED SOLUTION

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2021 01:48 PM
try
var string ='@@!H';
string = string.replace(/[\W_]/g, "_");
gs.print(string);
2 REPLIES 2

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2021 01:48 PM
try
var string ='@@!H';
string = string.replace(/[\W_]/g, "_");
gs.print(string);

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2021 01:50 PM
Hi,
Your post isn't too detailed for us to fully understand what you're meaning, but basically, you can use this to replace all special characters in a string to underscores:
var string = "field information here";
var test = string.replace(/[^\d\w]/gi, '_');
or...to check me...
var string = "I'mtheman(&*$#*&)@gmail.com";
var test = string.replace(/[^\d\w]/gi, '_');
gs.info(test);
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!