PHP正则实例:替换字符串开头和结尾的连续的逗号,包括中文和英文的逗号
PHP里使用正则表达式的一个实例,用来替换字符串开头和结尾连续的逗号,下面是具体的实例源码:
$s=",,,I,喜欢,黑帽联盟www.heimaolianmeng.com,,very,,,,";
echo(preg_replace("/^[,,]*||[,,]+$/","",$s));
?>
通过上面的实例,我们如果要替换连续的句号,只需要把上面正则里的逗号替换为句号就行了。
AD:真正免费,域名+虚机+企业邮箱=0元
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn