-1

I am trying to create regex expression (to use with Stylish extension for Firefox) that will render true for every string that has youtube.com, however will render false if string contains /user/ or /channel/.

Example

True
https://www.youtube.com/feed/trending

False
https://www.youtube.com/user/whateva/featured
https://www.youtube.com/channel/lfjafjsldsf

I don't even know where to start, tried to learn regex several times, but its beyond my understanding how it works.

Roman Toasov
  • 747
  • 11
  • 36

1 Answers1

1

I believe this should do it:

^.*youtube\.com((?!\/user\/|\/channel\/).)*$

See live demo

Proposed solution is using negative lookahead. For more information on that see:

Kamil Gosciminski
  • 16,547
  • 8
  • 49
  • 72