
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2019 10:27 AM
I'm trying to process a regex replace in a script include. The code will work in a background script, but fails in a script include.
regex: function(input) {
gs.info('input= '+input);
var cleaned = input.toString().replace(/[-+()\s]/g, '');
gs.info('A= ');
return cleaned;
the first gs.info will run, I never get anything from the second. What am I doing wrong?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2019 11:35 AM
A co-worker who is a much better developer than I found the issue. Apparently AJAX does not bring over the input as a true javascript string. I did see another post where someone mentioned the same thing, but that post didn't have a good way to correct it. The following line corrects the issue:
var stringInput = new String(input);
The script window complains about using String as a constructor, but it does fix the problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2019 11:22 AM
my script works.
replace yours with mine.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2019 11:35 AM
A co-worker who is a much better developer than I found the issue. Apparently AJAX does not bring over the input as a true javascript string. I did see another post where someone mentioned the same thing, but that post didn't have a good way to correct it. The following line corrects the issue:
var stringInput = new String(input);
The script window complains about using String as a constructor, but it does fix the problem.