Reputation: 3079
I got this
'','','{12345678},{87654321}','lk12l1k2l12lkl12lkl121l2lk12'
trying to match it using '(.*?)',|'(.*?)'
It successfully got my 4 chunks
''
''
'{12345678},{87654321}'
'lk12l1k2l12lkl12lkl121l2lk12'
But I am trying to use the same regex in split... it doesn't like it. :(
var str = "'','','{12345678},{87654321}','lk12l1k2l12lkl12lkl121l2lk12'";
str.split(/'(.*?)',|'(.*?)'/);
Any idea...? ugh.
Upvotes: 0
Views: 62
Reputation: 4360
Why are you using split
?
You can get your four chunks with match
:
var chunks = str.match(/'[^']*'/g);
Upvotes: 1
Reputation: 557
Is the split()
neccessary?
You could always get the information between the quotes using match()
.
test.match(/'(.*?)'/g)
Test it please.
Upvotes: 0