views:

79

answers:

2

To not match a set of characters I would use e.g. [^\"\\r\\n]*

Now I want to not match a fixed character set, e.g. "|="

In other words, I want to match: ( not ", not \r, not \n, and not |= ).

Thanks.

EDIT: I am trying to modify the regex for parsing data separated with delimiters. The single-delimiter solution I got form a CSV parser, but now I want to expand it to include multi-character delimiters. I do not think lookaheads will work, because I want to consume, not just assert and discard, the matching characters.

A: 

See this answer.

Anton Gogolev
I am not sure if lookaheads will work, but my understanding of it is still very limited. See the "EDIT" in my original post.
Peet Brits
A: 

I figured it out, it should be: ((?![\"\\r\\n]|[|][=]).)*

The full regex, modified from the CSV parser link in the original post, will be: ((?<field>((?![\"\\r\\n]|[|][=]).)*)|\"(?<field>([^\"]|\"\")*)\")([|][=]|(?<rowbreak>\\r\\n|\\n|$))

This will match any amount of characters of ( not ", not \r, not \n, and not |= ), or a quoted string, followed by ( "|=" or end of line )

Peet Brits