讨论:正则表达式替换! 我是这样做的:$string = preg_replace("/[^\r\n]\s+([\r\n$])/", "\\1", $string);不过连空行也删掉了! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 错了,是这样:$string = preg_replace("/\s+([\r\n$])/", "\\1", $string); $string = preg_replace("/\s+([\r\n]|$)/", "\\1", $string);上一句与这一句有什么区别!为什么这一句能将程序最后的空格删掉而上一句就不能呢? to:wangxiangjun_sun() 不愧是高手连这你也能看出来,还看出了什么? $string = preg_replace("/\s+([\r\n$])/", "\\1", $string);when "$" is inside [], it does not represent the end of string $string = preg_replace("/\s+([\x20]|$)/", "\\1", $string); $string = preg_replace("/\x20+([\r\n]|$)/", "\\1", $string); to:manyou(他山之石),zjj2002(阿俊)实验成功! $string = preg_replace('/([\r\n])[\s]+/', '\\1', $string); to:phpteam(好无聊) 不行啊! $_SERVER['PATH']值的问题 gif图片缩放的问题 php在线编辑的问题 新手 问个 特殊字符串的 保存方法 马上给分 php初学者 php实现不固定表单做ajax提交 版主请进来,请教一个问题。 phpmyadmin数据库管理中文显示问题!!? 请教php安装问题 "site map"=>"map.php"和$this->$name = $value里的=> ,->分别有什么不同 关于论坛在线用户显示模块实现的问题。 各位在设计表结构时,对字段有没有数量上的限制,一般为多少?
$string = preg_replace("/\s+([\r\n$])/", "\\1", $string);
上一句与这一句有什么区别!为什么这一句能将程序最后的空格删掉而上一句就不能呢?
不愧是高手连这你也能看出来,还看出了什么?
when "$" is inside [], it does not represent the end of string
实验成功!
不行啊!