I use text.replace(/\s/g, '')
to remove all whitespace characters from a String.
I'm trying this on a russian text. I do an alert(text)
which shows me the correct string, but the replace function throws this error - Bad Argument /\s/g
I'm creating .jsx files for Adobe InDesign scripting. The replace method works for some strings but fails sometimes. Any idea why?
Thanks.
EDIT
for (var i=0; i<arr.length; i++) {
// If there is no text for the current entry, remove it
alert(arr[i].text);
if (arr[i].text == undefined || arr[i].text === "") {
arr.splice(i,1);
i--;
continue;
}
var trimmed = arr[i].text.replace(/\s/g, '');
if (trimmed.text === "") {
entries.splice(i,1);
i--;
}
.
.
.
}