.net - Regex commas out of expression -


i attempting regex replace commas in-between quotations in string. can't seem match them in non-greedy fashion won't regex entire line. text , regex i'm trying below. regex i'm trying, picking commas in-between each element. ex "remove,comma","nocomma" yields "remove,comma" , "," match. also, picking matches "nocomma"," "nocomma","nocomma".

i working on matching first, narrowing down replacing commas.

using .net 4.0

text before regex

"remove,comma","remove,comma","nocomma","remove,comma","remove,all,commas,here,too","also,remove,commas"

text want after before regex

"removecomma","removecomma","nocomma","removecomma","removeallcommasheretoo","alsoremovecommas"

regex

\".*?(,).*?\" 

regex.replace(input,@",(?!([^""]*""[^""]*"")*[^""]*$)",""); 

the above regex replace , if odd number of " ahead..this because , within "" have odd number of " ahead.

[^"]* match 0 many characters not "

$ depicts end of string

(?!) negative lookahead


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -