I want to split a string in Javascript using the split function into 2 parts.
For example, I have a line:
str='123&345&678&910'
If I use javascripts split, he broke it into 4 parts. But I need it to be in 2 parts, only taking into account the first "&". with which he is faced.
As with Perl, if I use:
($fir, $sec) = split(/&/,str,2)
it splits str into 2 parts, but javascript only gives me:
str.split(/&/, 2); fir=123 sec=345
I need a section:
sec=345&678&910
How can I do this in Javascript.
kailash19
source share