Question User Question User - 1 year ago 64
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


Answer Source

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);

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download