Reputation:
I'm working on a csv file that was badly built, I created a regex that only matches quotes that ARE NOT delimiters, in this link I succeeded, however do you think you can optimize my regex to have only quotes and not the letters around, the constrait and that the quotation marks at the beginning or at the end are not taken into account, example:
"ModifTextePub";"ModifObservation";"Resume"Vitrine";"Observations"Criteres"";"InternetOK";"NumPhoto";"AmianteLe";"SNavantLe";"ActePrec";"ProprietairesPrec";"Situation";"FraisNotaires"
in this example it would be necessary to match only between Resume " Vitrine and also those around " Criteres "
The regex I am using is
(.){1}(?<!;|\n|\r|\t)(")(?!;|\n|\r|\t)(.){1}
with $1$3
as replacement.
Upvotes: 2
Views: 52
Reputation: 626689
Your regex with negative lookarounds containing positive character classes can be transformed into a pattern with positive lookarounds containing negated character classes:
(?<=[^;\n\r\t])"(?=[^;\n\r\t])
See the regex demo. The replacement will be an empty string.
Now, the match will only occur if there is a "
that is immediately preceded and followed with any char but ;
, CR, LF or TAB.
Upvotes: 0