Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

string split 1

Status
Not open for further replies.

devhelp

Programmer
Mar 29, 2006
3
CA
Hey guys
I have a string and I am using split() function on it like this

Code:
var words = s.value.split(" ");

but the above statement only splits on a blank space. I also want to split on ":" and "-". How do I do that.

I tried the following statement but it didnt work

Code:
var words = s.value.split(" |:|-");

any suggestions
 
I don't think split will let you use multiple. Would you be able to split it into words 1, 2, and 3, and then join all 3 arrays together?
 
Suppose one takes it for granted s.value is a string. Then it is this.
[tt] var words = s.value.split([blue]/[/blue] |:|-[blue]/[/blue]);[/tt]
Left-hand-side words is an array.
 
Thanks Tsuji
That works
Appreciate everyone's suggestions
 
Thanks tsuji! I didn't realize you could use a regular expression in a split! That little hint is worth a star!

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top