Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regexp: how to match everythings that is not into a pattern?

Tags:

regex

php

I want to match everything in a string that does not match a given pattern; for example [a-z].

Given the string abc4jkf8 4à3in, I need to match 48 4à3.

I've tried with ([a-z])+(?![a-z]) but this matches exactly the opposite of what I need. With the string above, this regexp matches abcjkfin.

Any ideas?

like image 636
Strae Avatar asked Jan 22 '26 04:01

Strae


1 Answers

You use a negative set:

([^a-z]+)
like image 115
Guffa Avatar answered Jan 24 '26 16:01

Guffa



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!