Click here to Skip to main content
15,885,546 members
Home / Discussions / Regular Expressions
   

Regular Expressions

 
AnswerRe: Regular expression to return all keys in a Bibtex file Pin
Richard Deeming5-Mar-23 21:36
mveRichard Deeming5-Mar-23 21:36 
GeneralRe: Regular expression to return all keys in a Bibtex file Pin
Member 159423566-Mar-23 19:48
Member 159423566-Mar-23 19:48 
AnswerRe: Regular expression to return all keys in a Bibtex file Pin
jschell8-Mar-23 6:57
jschell8-Mar-23 6:57 
QuestionRemove all double quotes not directly preceded or directly followed by a semicolon. Pin
Guus20053-Mar-23 3:55
Guus20053-Mar-23 3:55 
AnswerRe: Remove all double quotes not directly preceded or directly followed by a semicolon. Pin
Richard Deeming3-Mar-23 4:05
mveRichard Deeming3-Mar-23 4:05 
GeneralRe: Remove all double quotes not directly preceded or directly followed by a semicolon. Pin
Guus20053-Mar-23 5:19
Guus20053-Mar-23 5:19 
GeneralRe: Remove all double quotes not directly preceded or directly followed by a semicolon. Pin
Richard Deeming5-Mar-23 21:27
mveRichard Deeming5-Mar-23 21:27 
AnswerRe: Remove all double quotes not directly preceded or directly followed by a semicolon. Pin
jschell6-Mar-23 6:45
jschell6-Mar-23 6:45 
This is an example of why I always insist on tabs as a separator (not commas nor semi-colons.)

Guus2005 wrote:
Remove all double quotes not directly preceded or directly followed by a semicolon


You are trying to solve this incorrectly.

Guus2005 wrote:
1;200;345;"Apotheker "Blue tongue"";"Apeldoorn";12;"ABCD12"


You do not want to "remove" the double quotes because they are part of the value. The following is the correct value from the above.

Apotheker "Blue tongue"


The pattern for the CSV is as follows
1. Semi-colon separates values.
2. Some values are quoted (double quotes.)

For processing for the second case the following applies for the value (not the line but just a value from the line.)
1. The double quotes MUST be at both the end and start of the value. It is ignored if both are not true.
2. The double quotes in that case are removed. Double quotes internal are not impacted.

Additionally you need to deal with the potential that there is a semi-colon in the middle of a value.
If there is a semi-colon in a value then I doubt you should be using a regex to parse lines. Certainly if I was doing it I would not use a regex. Rather I would build a parser/tokenizer since the rules would be easier to see (and debug). Additionally it would probably be faster also.

The tokenizer makes the case with the semi-colon much easier to deal with. The tokenizer rule would be in general
1. Find a semi-colon (start at semi-colon.)
2. If the next character is a double quote, flag a rule that it must look for quote then semi-colon as next break.
3. If the next character is not a double quote, flag a rule that it must look for a semi-colon as next break.
Questionregex expression for us addresses Pin
jpcodex15321-Feb-23 14:55
jpcodex15321-Feb-23 14:55 
GeneralRe: regex expression for us addresses Pin
PIEBALDconsult21-Feb-23 15:02
mvePIEBALDconsult21-Feb-23 15:02 
GeneralRe: regex expression for us addresses Pin
jpcodex15321-Feb-23 15:25
jpcodex15321-Feb-23 15:25 
GeneralRe: regex expression for us addresses Pin
PIEBALDconsult21-Feb-23 15:30
mvePIEBALDconsult21-Feb-23 15:30 
GeneralRe: regex expression for us addresses Pin
Kenneth Haugland21-Feb-23 18:36
mvaKenneth Haugland21-Feb-23 18:36 
AnswerRe: regex expression for us addresses Pin
jschell22-Feb-23 6:06
jschell22-Feb-23 6:06 
GeneralRe: regex expression for us addresses Pin
trønderen22-Feb-23 12:04
trønderen22-Feb-23 12:04 
GeneralRe: regex expression for us addresses Pin
jschell23-Feb-23 6:09
jschell23-Feb-23 6:09 
GeneralWell no that isn't how it works Pin
jschell13-Feb-23 4:42
jschell13-Feb-23 4:42 
QuestionProblem combining REGEX expressions Pin
Member 156868422-Jan-23 18:40
Member 156868422-Jan-23 18:40 
AnswerRe: Problem combining REGEX expressions Pin
Member 156868423-Jan-23 3:25
Member 156868423-Jan-23 3:25 
GeneralRe: Problem combining REGEX expressions Pin
jschell24-Jan-23 10:38
jschell24-Jan-23 10:38 
Questioni need a regular expression to match a single word starting with m(...followed by any text but not space and )containing Manager Pin
anandssunku8-Jan-23 23:10
anandssunku8-Jan-23 23:10 
AnswerRe: i need a regular expression to match a single word starting with m(...followed by any text but not space and )containing Manager Pin
Richard Deeming9-Jan-23 0:07
mveRichard Deeming9-Jan-23 0:07 
AnswerRe: i need a regular expression to match a single word starting with m(...followed by any text but not space and )containing Manager Pin
jschell10-Jan-23 7:24
jschell10-Jan-23 7:24 
QuestionSometimes its a bullet item, sometimes it is not, sometimes it is multiple bullet items Pin
Member 158838933-Jan-23 22:31
Member 158838933-Jan-23 22:31 
AnswerRe: Sometimes its a bullet item, sometimes it is not, sometimes it is multiple bullet items Pin
OriginalGriff3-Jan-23 22:37
mveOriginalGriff3-Jan-23 22:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.