我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

正则表达式匹配数字和完整的sto并用空char替换它

I am trying to match digit and . and replacing it with "" no char.

$buffer= "test. 8090";

if PREG_REPLACE('/[0-9]+[.]/', '', $buffer)
{
echo $buffer;
}

http://ideone.com/KgFm3I

What's wrong here? gives syntex error

Put both digit and dot inside the character class []

$new_str = PREG_REPLACE('/[0-9.]+/', '', $buffer);
                              ^ here goes the dot

Don't put preg_replace inside the if statement,it doesnot return true or false.

Change the regex pattern like this \([\d+.])\

preg_replace("/[.\d]+/", "", $buffer);

近期文章

  • PHP致命错误:找不到类'imagecreatefromjpeg'
  • 获取html标记和特定字符之间的文本
  • 如何从php [duplicate]中删除String中的特定部分
  • PHP中的时间膨胀计算除以零?
  • 如何使用mktime获取今天的时间
  • php中的scandir与特殊(匈牙利)字符
  • PHP正则表达式在文本之前获取数字
  • 重载函数如何区分输入的梯形三个变量和三角形的三边。
  • World's Worst Bus Schedule 调度的算法
  • Fermat vs. Pythagoras 代码设计
  • Coconuts, Revisited 程序是怎么编写
  • Doing Windows 代码编写的过程
  • Word Amalgamation 程序设计思路
  • Pipe Fitters 怎么实现的呢
  • Game Prediction 代码的实现
  • Moving Object Recognition 运动的对象的识别
  • Radar Installation 雷达的安装算法
  • 过三点如何画圆,Circle Through Three Points
  • Multiply C语言实现
  • Finding Liars 代码编写是什么思路

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华