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

php替换以小写字母结尾的单词末尾的逗号

I have a string like this: 2D-Digital, 1:10PM, 3:10PM, RealD-3D, 5:15PM What I need is a string like this 2D-Digital: 1:10PM, 3:10PM, RealD-3D: 5:15PM

I thought about using preg_replace on the string to find the words that end with a letter and then replace the , into a : but the problem with that is the 3:10PM and such also end with a letter. Please help me.

You can use a negative and positive look-behind to find the desire commas :

(?<![AP]M)(?<=[a-zA-Z]),

see demo https://regex101.com/r/hD7bE6/2

近期文章

  • proteus引脚灰色
  • Failed to download metadata for repo 'libnvidia-container'
  • 训练鸢尾花数据集,准确率要越高越好
  • C语言返回值问题(力扣刷题)
  • Rmarkdown输出为word文档不显示结果
  • java-RMI编程 eclipse生成不了存根问题
  • 大一网络应用技术测试
  • 在php中意外结束文件?
  • 请问第13行是什么意思呢
  • sqlsession用aop代理来完成报错
  • 想问一下s函数怎么在simulink的块中添加啊 每次浏览完毕添加都没反应
  • 三个数组合成数运算编程
  • sudo rosdep init出现的问题
  • 无语了,这个js的代码也写错了吗?我怎么感觉没错啊,但是就是删除不了也替换不了,求解详解必采纳
  • python与lammps
  • java的Jackson什么用
  • 将旧的过程PHP函数转换为Codeigniter中的模型 - 视图 - 控制器(MVC)
  • 怎么修改jframe窗口图标的大小?
  • Linux里面dhcp的实验
  • EDA技术跨选EDA

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

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

友情链接:代码精华