M
Mikus Sleiners
I'm using following regex expression in C#
Regex regex = new Regex("(\"(?:[^\"]|\"\")*\");?");
return regex.Match(input);
I use it to split up input like this
"LV27HABA0551004004467";"20";"01.07.2009";"RIMI Kr.Valdemara 112
Riga";"PIRKUMS 4205734302189310 29.06.2009 2.48 LVL (502500) RIMI
Kr.Valdemara 112 Riga
";"2.48";"LVL";"D";"2009070100101359";"CTX";"";"";
as you can see this is a line of comma sepparated values and this regex
works lightning fast and does the job except I have one major problem
sometimes input comes like this
"some value"; "some value"; "supermarket "The best" rozmarine street
222";"some value"; "some value";
The problem is that my current regex expression cannot handle quotes insode
quotes ... in this example "the best" comes enclosed in quotes which
causes regex engine to split up this line incorrectly and thus leads to
exception later in my code
I need a way to correct the expression so that it matches only if there is a
quote followed by ";" this way it would work correctly even with quotes.
Is there an easy way to fix this?
P.S sorry for posting this on c# group... i didn't find any regex related
place so i picked this one
Regex regex = new Regex("(\"(?:[^\"]|\"\")*\");?");
return regex.Match(input);
I use it to split up input like this
"LV27HABA0551004004467";"20";"01.07.2009";"RIMI Kr.Valdemara 112
Riga";"PIRKUMS 4205734302189310 29.06.2009 2.48 LVL (502500) RIMI
Kr.Valdemara 112 Riga
";"2.48";"LVL";"D";"2009070100101359";"CTX";"";"";
as you can see this is a line of comma sepparated values and this regex
works lightning fast and does the job except I have one major problem
sometimes input comes like this
"some value"; "some value"; "supermarket "The best" rozmarine street
222";"some value"; "some value";
The problem is that my current regex expression cannot handle quotes insode
quotes ... in this example "the best" comes enclosed in quotes which
causes regex engine to split up this line incorrectly and thus leads to
exception later in my code
I need a way to correct the expression so that it matches only if there is a
quote followed by ";" this way it would work correctly even with quotes.
Is there an easy way to fix this?
P.S sorry for posting this on c# group... i didn't find any regex related
place so i picked this one