用Dot(.)RegEx php替换逗号(,) [英] Replace Comma(,) with Dot(.) RegEx php
本文介绍了用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);
这篇关于用Dot(.)RegEx php替换逗号(,)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文