需要正则表达式在“点”之前和之后添加空格,但在十进制数字上没有

i need a regex that replaces the char "." with a blank space before and after " . ", but only if the point is not part of a number (decimal point):

example:

test. of my country.brazil, should be 38.45

It should return:

test . of my country . brazil, should be 38.45

Any one can help ?

Thanks

This should do the trick:

<?php

$regex = '/([^0-9])\s?\.\s?([^0-9])/';
$string = 'test. of my country.brazil, should be 38.45';
$replace = '$1 . $2';
echo preg_replace($regex, $replace, $string);
//test . of my country . brazil, should be 38.45