Home  >  Article  >  Backend Development  >  php和editplus正则表达式去除空白行,editplus正则表达式_PHP教程

php和editplus正则表达式去除空白行,editplus正则表达式_PHP教程

WBOY
WBOYOriginal
2016-07-13 09:56:55717browse

php和editplus正则表达式去除空白行,editplus正则表达式

去除字符串内部的空行:
复制代码 代码如下:
$str = preg_replace("/(\s*?\r?\n\s*?)+/","\n",$str);

去除全部的空行,包括内部和头尾:
复制代码 代码如下:
$str = preg_replace('/($\s*$)|(^\s*^)/m', '',$str);

editplus中替换空白行的正则表达式:

正则表达式:^[\t\n ]*\n

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/985271.htmlTechArticlephp和editplus正则表达式去除空白行,editplus正则表达式 去除字符串内部的空行: 复制代码 代码如下: $str = preg_replace("/(\s*\r\n\s*)+/","\n",$str)...
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