针对http://expert.csdn.net/Expert/topic/1348/1348353.xml?temp=.2064783
对字符串中的源程序作删除尾部空格操作:
也就是说:将一个php源程序存入一个字符串变量以后,将字符串中的源程序的尾部空格删除(相当于在editplus中对程序代码作删除尾部操作)。
---------------------------------------------------------------
一句字符多,一句字符少
---------------------------------------------------------------
$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);
---------------------------------------------------------------
$string = preg_replace('/([\r\n])[\s]+/', '\\1', $string);