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

php使用通配符查找并替换使用字符串

I have strings in my html like this >> &rf=238255238255238255

So thats >> &rf= (and 18 random digits)

How do I find that with a view to replacing it with ... ?

My own &rf=0101010101010101

Well, you can capture it using regex and replace it whatever value you want.

Your regex will be "/(?<=&rf=)\\d+/"

$re = "/(?<=&rf=)\\d+/"; 
$str = ">> &rf=238255238255238255"; 
$subst = ""; 

$result = preg_replace($re, $subst, $str);

See Demo here.

近期文章

  • PHP设置cookie适用于测试系统,而不适用于实时系统
  • 在Date字段的非对象上调用成员函数
  • 可以在上传图片后添加ajax获取值吗?
  • Omnipay Paypal Express重定向显示重定向消息
  • 如果只使用日期,PHP DateTime避免设置语言环境
  • 如何将新页面添加到laravel框架的管理视图中
  • 在iframe和主页之间安全地交换数据
  • Volley Server错误(需要javascript?)Android开发
  • 无法通过Gmail发送电子邮件
  • Woocommerce - 根据变化列出产品
  • 复选框选择JavaScript以显示后端php所需的结果
  • 将PHP MongoDb驱动程序从mongo v1.6.12升级到mongodb v1.4时出错
  • 如何解析Magento SOAP V1 Php类别树
  • 使用htaccess进行mod-write动态链接不起作用
  • 密码检索系统不发送电子邮件codeigniter
  • 优化与MySQL查询的慢速匹配
  • WordPress:需要更改RSS Feed中的帖子永久链接URL
  • 在phpMyAdmin中自动化MySQL
  • 登录失败时请勿刷新
  • 从Android到PHP的POST LineString

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

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

友情链接:代码精华