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

PHP - 正则表达式从字符串的开头和结尾删除单引号

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.

You don't really need a regex for this; you can just use trim(), as in trim($string, "'").

If you really want a regex for some reason, this one would do it:

/^'+|'+$/

Just replace with ''.

近期文章

  • mysql SOCKET,PIPE,SHARED MEMORY 三种连接方式c++怎么写
  • labview程序错误
  • window 导出正常,linux导出有问题
  • System.ObjectDisposedException:“无法访问已释放的对象。 ObjectDisposed_ObjectName_Name”
  • 雷达点云数据转换为三维坐标
  • 想买笔记本,这个配置能带动ue5吗?
  • 虚拟机运行不了Mysql
  • cmake编译opencv时,fatal error LNK1104: 无法打开文件“kernel32.lib”错误
  • docker会kill进程吗
  • Laravel - 从字符串路径获取文件实例
  • electron打包make后的exe模块运行不正常
  • python 安装 cryptography==2.8 报错
  • def 函数返回为类对象
  • win10任务栏预览小窗口怎么调出
  • 关于#sql#的问题:行列转换时,由于不知道要转换成列的字段有几种值
  • 关于#c语言#的问题,如何解决?
  • xsl:if 函数中$BR什么含义?
  • 请问我这样写是出现了什么问题为什么会出这样的错误
  • plc与上位机tcp通信端口号只能用9600吗
  • 如何将子菜单添加到WordPress管理栏

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

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

友情链接:代码精华