Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Ignore An Character With Random Numbers Using RegEx?

Tags:

regex

I am trying to ignore the character @ with random numbers combined using RegEx.

This is what I don't want to detect:
@1235

This is what I want to detect:
12345

This what I did so far:

(?!@[0-9])([0-9])

1 Answers

You can use

(?<![@\d])\d+

See the regex demo. Details:

  • (?<![@\d]) - a negative lookbehind that fails the match if there is a @ or a digit immediately to the left of the current location
  • \d+ - one or more digits.

See the regex graph:

enter image description here

like image 158
Wiktor Stribiżew Avatar answered Oct 26 '25 08:10

Wiktor Stribiżew



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!