I want to split '9088{2}12{1}729'
into [ "9088", "{2}12", "{1}729" ]
or even more useful to me: [ "9088", "2-12", "1-729" ]
tried:
'9088{2}12{1}729'.split(/\{[0-9]+\}/); => ["9088", "12", "729"]
also tried:
'9088{2}12{1}729'.match(/\{[0-9]+\}/); => ["{2}"]
I know it probably involved some other regexp string to split including delimiters.
Tried it in php, I guess you can do it in one line also.
preg_split( '/{/', preg_replace( '/}/', '-', "9088{2}12{1}729" ) )
Array ( [0] => 9088 [1] => 2-12 [2] => 1-729 )
Just have to wrap the replace function with split to get the preference order correct.
I think I like js more :)