-1

I would like to come out with a regex expression that negate the matched results of regex expression: .google.*search. And, is it possible to achieve it with regex from the regex expression I am trying to negate?

Test data

[1] https://www.google.com/search?newwindow=1&sxsrf=ALeKk02MzEfbUp3jO4Np
[2] https://github.com/redis/redis-rb
[3] https://web.whatsapp.com/

Expected result

Row 2, 3 match the regex pattern and are part of the results.

Melvin
  • 359
  • 2
  • 16

2 Answers2

0

the following regex does the trick

^(?!.+google.*search)

basically matching the beginning of the line then negating (?!) (negative lookahead) your regex.

Abdessabour Mtk
  • 3,677
  • 2
  • 9
  • 21
0

You may use a negative lookahead here:

https?:\/\/(?!.*\.google\..*search).*

Demo

The "secret sauce" here is (?!.*\.google\..*search), which asserts that .google. followed by search does not occur anywhere within the URL to the right of the https:// portion.

Tim Biegeleisen
  • 387,723
  • 20
  • 200
  • 263