Regex Expression to allow comma only inside a string (within quotes)and not outside it -
i kind of new regex. looking regex expression add constraint not allow comma outside string .
my input
"1,212121,121212","extra_data"
here regex expression should not check comma in first value within quotes "1,212121,121212"
should check after quotes including ,"extra_data"
. in short expression should allow comma in string inside quotes , not outside.
kindly me expression.
i think you're looking for, group of numbers or commas surrounded parentheses followed comma , phrase (not numbers) in parentheses. capturing group #1 gives "1,212121,121212" , capturing group #2 gives ,"extra_data"
("[\d,]+")(,"[^"]+")
it helpful see more of how input might come in. think biggest question remains whether first group contain numbers/commas, or there other characters such letters, underscores, etc in first group? if first group contains numbers, i've assumed, should work. if doesn't, not work.
edit:
"\s*(,\s*"[^"]+")
Comments
Post a Comment