mardi 4 juillet 2017

c++11 regex lookahead exclude word

I have a string list:

  1. ReferencePrice
  2. ReferenceCurrentPrice
  3. CostPrice
  4. AverageCostPrice ...

I want to filter out all strings that:

  1. Containing 'Price',
  2. But not containing 'CostPrice'

My regex is '(?!Cost)Price', but it can match the 3rd string 'CostPrice', why? and what is the correct regex?

Aucun commentaire:

Enregistrer un commentaire