Regex to remove pattern from sequence
Hi,
I have a sequence of strings seperated by a comma.
1x,2x,1y,2y,1aa,2aa,1bb,1cc,2bb,2cc
I want to remove all of the strings starting with 2. So my string would look like this:
1x,1y,1aa,1bb,1cc
I want to maintain the comma delimiter. Note the end of the sequence does not have a comma.
Currently I am using:
var s = "1j,2j,1vv,2vv,2xx,1N,2Y,1abc";
s = ( s.replace ( "2[^,]*", "", "g"));
alert ( s );
But I get left with double comma, which I clean up later.
Any suggestions for a better, faster solution, would be very welocome.
Thanks.
P.
