Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

REGEX no numbers or ( )

Tags:

regex

I need a regular expression that accepts everything except numbers and ( & ). I'm trying but I can't seem to get it. Can anybody help me with this regex hell?

Example:

Hans Pedro (23123123) should be Hans Pedro. But the format can be different anytime.

like image 993
Wesley Lalieu Avatar asked Feb 20 '26 00:02

Wesley Lalieu


2 Answers

You can use:

^[^0-9()]+$

like image 192
codaddict Avatar answered Feb 21 '26 12:02

codaddict


Something like so: ^[^\d()]+$ should do what you need. It will start from the beginning of the string (^) and match one or more characters which are not a digit (\d) or a bracket. It will keep doing this till it finds the end of the string ($).

like image 44
npinti Avatar answered Feb 21 '26 14:02

npinti