- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11 hours ago
Morning All
I have an issue with a script that I am using to set a flow variable within Integration Hub. I require the script to remove ALL spaces in a text string, but it does not work.
Here is my script:-
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11 hours ago
Hi @jonathangilbert ,
It's not replaceALL (javascript is case-sensitive), use replaceAll(" ","")
Thanks
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11 hours ago
Hi @jonathangilbert ,
It's not replaceALL (javascript is case-sensitive), use replaceAll(" ","")
Thanks
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
9 hours ago
Hello
Since you want to remove ALL spaces, including multiple spaces around hyphens, use a regular expression
var first = fd_data.subflow_inputs.first_name.toLowerCase();
var first2 = first.replace(/\s/g, "");
return first2;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
9 hours ago
Hello @jonathangilbert
You can try either of these two approaches:
1. Use replaceAll()
JavaScript is case-sensitive, so replaceALL() is not a valid method. The correct method is replaceAll() with a lowercase l:
name.replaceAll(" ", "");
2. Use a regular expression
You can also use a regex with the global (g) flag to remove all whitespace:
name.replace(/\s/g, "");
Hope this helps!
Thank You!
Juhi Poddar
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
9 hours ago
Thank you so much Anand, that worked. I only used ALL as that is what I had seen in a Google search result