Hello.

I have a regular expression.

$match = '43243'; @preg_match('([0-9]+)', $match, $title); echo $title[1]; 

In general, the problem is this: it finds regular numbers, but you need to not find numbers when there are also symbols in $match . How to do?

  • \ d >>>> [0-9] - etki

2 answers 2

Everything except numbers:

 preg_match('/[^\d]+/', 'foo123bar', $match); var_dump($match); 

For multiple occurrences:

 preg_match_all('/[^\d]+/', 'foo123bar', $match); var_dump($match); 

PS Using the error cancellation operator @ is bad form. In this particular case, it is generally impractical.

  • > Using the error cancellation operator @ is bad form. worse only comma between subject and predicate - etki

You can try this:

 ^[0-9]+$ 

P.S. Do not use "@" dogs in the code, please.

  • @ czart2014, If you are given an exhaustive answer, mark it as correct (click on the check mark next to the selected answer). - ReinRaus