Home arrow static arrow Java Programming [Archive] - StringTokenizer equivalent for Javascript
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - StringTokenizer equivalent for Javascript
This topic has 4 replies on 1 page.

Posts:82
Registered: 7/8/99
StringTokenizer equivalent for Javascript  
Jul 30, 2004 6:18 AM



 

Is there a StringTokenizer equiv in Javascript?

i.e. I hava string test|test|test|test

I want to tokize in JS and then iterate through the tokens.
 

Posts:319
Registered: 11/8/00
Re: StringTokenizer equivalent for Javascript  
Jul 30, 2004 6:22 AM (reply 1 of 4)



 
yep, the split() method
 

Posts:319
Registered: 11/8/00
Re: StringTokenizer equivalent for Javascript  
Jul 30, 2004 6:24 AM (reply 2 of 4)



 
sorry a bit over egger on posting that

"123,456,789".split(","); // Returns ["123", "456", "789"]

It can also take a regular expression
 

Posts:192
Registered: 30/05/01
Re: StringTokenizer equivalent for Javascript  
Jul 30, 2004 6:28 AM (reply 3 of 4)



 
have a look at String.split

String.split([separator][, limit])

I think it returns an array of Strings
 

Posts:192
Registered: 30/05/01
Re: StringTokenizer equivalent for Javascript  
Jul 30, 2004 6:29 AM (reply 4 of 4)



 
note to self
must refresh before posting
 
This topic has 4 replies on 1 page.