0

Possible Duplicate:
Regular expression to match string not containing a word?

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 |= ).

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.

Community
  • 1
  • 1
Peet Brits
  • 1,988
  • 21
  • 41
  • @George, how is this an exact duplicate? Yes, both are resolved with negative lookaheads, but mine required multiple matching sequences. – Peet Brits Jul 27 '12 at 07:22

1 Answers1

0

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
  • 1,988
  • 21
  • 41