Regex to remove numbers if not in a url

  php, regex

I’m using this regex to remove number in a string and it works fine for that

$story = preg_replace('/+?[0-9][0-9()-s+]{4,20}[0-9]/', '', $story);

My problem is that is do not want to remove numbers if they are part of a url for ex.

domain.com/page/?id=article_1625463

Is it possible just to remove it from other parts of the string.

So this:

Call our company on 3453453454 or 0045 345 532 34 or visit our website domain.com/page/?id=article_1625463

Becomes:

Call our company on or or visit our website domain.com/page/?id=article_1625463

Source: Ask PHP

LEAVE A COMMENT