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

preg_replace regex for(123):

I'm looking for a preg_replace regex that will match and remove

(123):

and

(+12):

I've tried a few including

$str = preg_replace('/([0-9]+)/s', '', $str);

but none I've tried have removed the () brackets/parentheses nor the + sign

(yes I realise the + in the regex means plus/continue not an actual + sign) ;)

You need to escape the parenthesis and add the + sign to your character group:

$str = preg_replace('/\([+0-9]+\)/s', '', $str);

近期文章

  • PHP下一个($数组)和Javascript
  • mysql_real_escape_string()但允许带撇号的名称
  • 如何在PHP中使用连接字符串构建树?
  • 发布包含撇号的php变量
  • 将时间存储到数据库并与当前时间进行比较
  • 如何使用'if'重定向[关闭]
  • 从PHP调用Ajax来执行单独的PHP; 有危险吗?
  • 用拉丁语对应替换外来字符,用连字符替换空格(PHP)
  • 检查条件下是否存在行(PDO,准备???)
  • 用hasrsine和float计算距离...有点工作
  • 来自MYSQL的php下拉菜单,如何返回其他列值?
  • 用一个循环打印两个数组
  • Jquery设置PHP $ _GET数组
  • sqlserver + php:刚刚插入行id
  • datetime转换到日期只有php
  • 表单中的日期并验证
  • 元描述的正则表达式代码是什么
  • 用PHP和Jquery替换Span数据
  • 随机化多维数组中的数据(第二层)
  • 将函数作为参数传递给另一个函数

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

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

友情链接:代码精华