Home  >  Article  >  Backend Development  >  怎么控制在正则替换时,保留原来的值

怎么控制在正则替换时,保留原来的值

WBOY
WBOYOriginal
2016-06-13 13:27:131043browse

如何控制在正则替换时,保留原来的值
$s =

1范围

2规范性引用文件

3单位和定义

TXT;

像上面这种我要改成:
$s =
1范围

2规范性引用文件

3单位和定义

TXT;

就是把有些02135.pdf.htm,02136.pdf.txt这类pdf的后缀去掉

我的想法是替换成空,不知道这个方法好不好,但是其他的值的控制我就不会了


PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
$s = ('/<div id="divPdf.*?title=" .. echo>
<br>我是这样写的,不过貌似没有成功<br><br><br><font color="#e78608">------解决方案--------------------</font><br>
<fieldset>
<legend>探讨</legend>
<br>楼上正解<br>如果我想把<div id="divPdf3" title="前面这里加上来确保修改的是<div id = .... pdf  这些行呢.</fieldset> <div class=" clear>
                 
              
              
        
            </div>
</fieldset>
</div>
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