Question User Question User - 2 months ago 9
PHP Question

how to remove the particular string using preg match in php

I need to remove the

from the vairable how can i do that ?


Expected Output


how can i achive this using preg_match or preg_replace something.

The value will be dynamic something like this



Try this:

$newstr = preg_replace("/(?:\w\.|\w\w\.)/", "$2", $variable);

It will remove one or two leading chars and a dot.

Or simply : $newstr = preg_replace("/(?:\w+\.)/", "$2", $variable);