Delete only numbers in brackets (brackets)

Using the code below, I can turn Number123(45)into Number.

$string = 'Number123(45)';
$string2 = preg_replace('/[0-9]+/', '', $string);
echo $string2;

How would I just delete the numbers in parentheses (brackets) so that the output is Number123()?

+4
source share
1 answer

Include parentheses in the template, for example:

$string = 'Number123(45)';
$string2 = preg_replace('/\([0-9]+\)/', '()', $string);
echo $string2;

Conclusion:

Number123 ()

+5
source

Source: https://habr.com/ru/post/1651327/


All Articles