-1

I'm trying to find matches for Instagram handles but ignore specific handles.

I'm using

@[A-Za-z0-9\.\_]+

to match any handle starting with an @ sign, but I want to ignore handles like @example and @test which for that I have the regex @example|@test.

New to regex and trying to figure out how to do the look ahead and ignore the example and test cases. Not sure how to combine the two into one.

CinCout
  • 9,486
  • 12
  • 49
  • 67
user3242036
  • 645
  • 1
  • 7
  • 16

1 Answers1

0

Do this:

@(?!example|test)[A-Za-z0-9._]+

Uses negative lookahead to ignore the handles that are not required.

Demo

CinCout
  • 9,486
  • 12
  • 49
  • 67