如何删除字符串中的引号? [英] How do I remove quotes from a string?
本文介绍了如何删除字符串中的引号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$string = "my text has \"double quotes\" and 'single quotes'";
如何从$string
删除所有类型的引号(不同的语言)?
How to remove all types of quotes (different languages) from $string
?
推荐答案
str_replace('"', "", $string);
str_replace("'", "", $string);
我认为您是指引号吗?
否则,请使用一些正则表达式,这将适用于html引号,例如:
Otherwise, go for some regex, this will work for html quotes for example:
preg_replace("/<!--.*?-->/", "", $string);
C风格的引号:
preg_replace("/\/\/.*?\n/", "\n", $string);
CSS样式的引号:
preg_replace("/\/*.*?\*\//", "", $string);
bash风格的引号:
bash-style quotes:
preg-replace("/#.*?\n/", "\n", $string);
等等等等
这篇关于如何删除字符串中的引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文