cancel
Showing results for 
Search instead for 
Did you mean: 

Javascript function split not working

kamielvdz
Champ in-the-making
Champ in-the-making
When I try to use the split funtion in javascript in a webscript on a string it always returns 0 elements.

e.g.

var test = "test.string.test";
var testArray= test.split(".");

testArray is alway empty.

I'm guessing this has to do with the javascript implementation used by the webscripts.

It's easy enough to work around, but thought I should mention it.
3 REPLIES 3

mikeh
Star Contributor
Star Contributor
Not seeing that at all…
% var test = "test.string.test"; var testArray= test.split(".");
% testArray.length
3

Make sure you've got a JavaScript string and not a Java string when trying to call split(). You can force a JavaScript string using String().

Thanks,
Mike

kamielvdz
Champ in-the-making
Champ in-the-making
Thx. That was indeed the problem.

Would rather see an error or null object returned than an empty array though.

mikeh
Star Contributor
Star Contributor
Would rather see an error or null object returned than an empty array though.
Feel free to raise a bug at Mozilla against the Rhino engine - that's "just how it works" I'm afraid.

Thanks,
Mike
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.