如何在php中使用preg_match删除特定的字符串

I need to remove the v. from the vairable how can i do that ?

$variable='v.vm_name,p.companyid';

Expected Output

$variable='vm_name,companyid';

how can i achive this using preg_match or preg_replace something.

The value will be dynamic something like this

 $variable='b.vm_name,tt.companyid';

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

Here`s a solution:

$variable = 'b.vm_name,tt.companyid';
$variable = preg_replace('/[a-z]+\./', '', $variable);

it will remove every dotted prefix before column names.