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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing more than one argument to SPLIT

Status
Not open for further replies.

Ito2233

MIS
Sep 2, 2003
77
0
0
US
Can I have more than one argument serve as the delimiter in the SPLIT method? Whenever I read about SPLIT, I read about passing one delimiter to it. However, I need to split a string on encountering both an "=" sign and a ";". Is there a way to do it?
Thanks
 
Try this, before using the split change all your '=' and ';' to a character you are sure won't be used in your string. Something like '~' or 'ç' or even '^'.
Then do the split using the chosen character.



grtfercho çB^]\..
"Imagination is more important than Knowledge" A. Einstein
-----------------------------------------------
 
Alternatively I guess you could just replace all your '=' to ';' and then use the split.

grtfercho çB^]\..
"Imagination is more important than Knowledge" A. Einstein
-----------------------------------------------
 
Grtfercho, how do I perform this character replacement? Is there a special function for it?
 
Code:
var the_string = "safjkl=ffd;dfsdf=dfsdf;fds=fd";
the_string.replace("=",";");
alert(the_string);

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
Pass it a regular expression:
Code:
<script>
var the_string = "safjkl=ffd;dfsdf=dfsdf;fds=fd";
the_string=the_string.split([b]/=|;/[/b]);
alert(the_string);
</script>

Adam
while(ignorance){perpetuate(violence,fear,hatred);life=life-1};
 
or another example just for nonsense:
Code:
<script>
var the_string = "safjkl=ffd;dfsdf=dfsdf;fds=fd";
the_string=the_string.split("=").join(";").split(";");
alert(the_string);
</script>

-kaht

banghead.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top