Link to home
Start Free TrialLog in
Avatar of dshrenik
dshrenikFlag for United States of America

asked on

javascript - split strings

I want to split a string according to this example:
"a|b||c||d|e"
into
"a"
"b"
""
"c"
""
"d"
"e"

If possible, please provide some sample code. Thanks!

Avatar of pivar
pivar
Flag of Sweden image

Hi,

Use split function

.split("|");

<script type="text/javascript">

var str="a|b||c||d|e";

document.write(str.split("|") + "<br />");

</script>

It will give you an string array.


/peter

ASKER CERTIFIED SOLUTION
Avatar of pivar
pivar
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial