我想从字符串中删除单引号,而不是撇号引号。
例如:
请点击“这里”选择您想登录的帐户
我需要它就像
请点击这里选择您想登录的帐户。
我试过像这样
$text = preg_replace( '/[^\da-z ! ?.]/i', ' ', $text );但它正在删除所有单引号。任何帮助都很感激。经过长时间搜索后,在堆栈溢出中没有找到任何解决方案。
发布于 2018-01-11 15:30:43
模式:/\B'|'\B/
代码:(演示)
$text="Please click 'here' to choose the account you'd like to 'Login'";
$text = preg_replace("/\B'|'\B/",'', $text);
echo $text;输出:
Please click here to choose the account you'd like to Login要处理girls' dresses这样的复数所有名词(或我们称之为它们的任何名词),下面是一个更有力的调用:
$text="Please click 'here' to choose the users' accounts that you'd like to 'use'";
$text = preg_replace("/\B'([a-z-]+)'\B/i",'$1', $text);
echo $text;输出:
Please click here to choose the users' accounts that you'd like to usehttps://stackoverflow.com/questions/48210490
复制相似问题