Regular Expression Mmatch, but excluding a subset of those matches

  • Thread starter Thread starter KimPark
  • Start date Start date
K

KimPark

Guest
I have a block of text with the rows:

Lorem ipsum dolor congue ligula sit ametconsectetur
congue ligula:Sed sit amet ipsum mauris. Maecenas
congue ligula:
consectetur ante hendrerit. Donec congue ligula
ac quam congue ligula viverra nec

where I want to conduct a regular expression match for any rows containing congue ligula.

For that, I have this regular expression:

(.)*(congue ligula)(.)*

But Id like to exclude a subset of those rows, specifically:

Case 1: congue ligula:
Case 2: ac quam congue ligula viverra nec

Is there anyway to say "Match all these" [(.)*(congue ligula)(.)*], but exclude these specific matches [a full line being = "congue ligula:" or "ac quam congue ligula viverra nec"]?

Anyone have any regular expression advice on this one? For the sake of code flexibility, I dont want to place conditional statements in the code to filter this out and want it handled SOLELY in regular expressions, if thats at all possible.



Thanks!

Continue reading...
 

Similar threads

Back
Top