用Dot(.)RegEx php替换逗号(,)

问题描述:

我正在尝试此代码,但出现此错误:No ending delimiter '/' found

i am trying this code but i get this error: No ending delimiter '/' found

$form = " 2000,50";
$salary = preg_replace('/',', '.'/', $form); // No ending delimiter '/' found 
echo $salary;

我不确定正则表达式验证.

I am not sure about the regex validation.

正则表达式对于仅替换单个字符来说是过大的杀伤力.为什么不这样做呢?

Regex is overkill for replacing just a single character. Why not just do this instead?

str_replace(',', '.', $form);