I have a string variable like $string = "'dj12JKmi3433Kl09'"
. How to remove the single quotes '
from the beginning and end of the string using a preg_replace
function? Thanks for your help.
PHP - 正则表达式从字符串的开头和结尾删除单引号
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- dqpkea9486 2015-06-10 03:16关注
You don't really need a regex for this; you can just use
trim()
, as intrim($string, "'")
.If you really want a regex for some reason, this one would do it:
/^'+|'+$/
Just replace with
''
.本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 maixpy训练模型,模型训练好了以后,开发板通电会报错,不知道是什么问题
- ¥30 截图中的mathematics程序转换成matlab
- ¥15 动力学代码报错,维度不匹配
- ¥15 Power query添加列问题
- ¥50 Kubernetes&Fission&Eleasticsearch
- ¥15 有没有帮写代码做实验仿真的
- ¥15 報錯:Person is not mapped,如何解決?
- ¥30 vmware exsi重置后登不上
- ¥15 c++头文件不能识别CDialog
- ¥15 Excel发现不可读取的内容