0

I'm using RegexBuddy and getting nowhere defining a search parameter for editpad.

I'm trying to search through my CMS web site for all instances of "http://" (to see where the protocol was hardcoded incorrectly), but every file has "http://particular.domain.com" in the comments near the top of the file.

How can I search for all EXCEPT those? This seems like it should be basic.

bcsteeve
  • 973
  • 9
  • 22

2 Answers2

1

Here's your expression:

http:\/\/(?!particular\.domain\.com).+

Check out a demo here: https://regex101.com/r/eT2cX8/2

This portion is called a negative lookahead that lets you negate that match:

(?!particular\.domain\.com).+
p e p
  • 6,593
  • 2
  • 23
  • 32
  • Thanks. I did read about negative lookaheads and somehow wasn't able to get it all together. It makes sense now. Thanks. – bcsteeve Oct 15 '15 at 23:39
  • I've always thought that term makes it sound really confusing. – p e p Oct 15 '15 at 23:45
  • So then I started thinking.. maybe I could use a negative look behind to cut out anything that's in a comment. So I tried this: http:\/\/(?<!\/\/).+ but got no love. What am I missing there? – bcsteeve Oct 16 '15 at 00:00
1

use a negative lookahead:

'(?!http://particular.domain.com)http://'

is an example of a pattern that would match any http:// text EXCEPT the particular one

R Nar
  • 5,465
  • 1
  • 16
  • 32