删除< br/>从< pre>内部</pre>标签 [英] Remove <br /> from inside <pre> </pre> tag
问题描述
我制作了简单的BBCode脚本,并且一切正常.但是后来,我使用了一个JavaScript库来美化<pre></pre>
中的代码.
I made simple BBCode script and it works all fine. But then later i use a javascript library to beautify my codes in <pre></pre>
.
现在,我面临的唯一问题是,在<pre></pre>
标签中的每一行代码之后都有<br />
标签.
Now the only problem I am facing that I have <br />
tags after each line of code in <pre></pre>
tags.
所以问题是如何删除仅内在 <pre></pre>
标签的<br />
标签.
So the question is how could I remove the <br />
tags which ARE INSIDE the <pre></pre>
tags only.
带有preg_replace的正则表达式似乎是我需要的东西,但我找不到/制作一个符合我的需要的东西.我对正则表达式不太满意. :S
A regex with preg_replace seems to be the thing i need but I could not find/make one to match my need. I not much good with regex. :S
推荐答案
能否请您提供一个您想测试的代码示例.
Could u provide us an example of the code u want to test please.
模式应如下所示:'/.*<pre>.*(<br \/>).*<\/pre>/'
这是我尝试的链接: https://regex101.com/r/pV2qX8/2
Here is the link of my try : https://regex101.com/r/pV2qX8/2
注意:您可以反转捕获括号-只是为了表明您仅捕获了<pre></pre>
内部的<br />
.
NOTE : u can reverse the capturing braces - It was just to show u it catched only the <br />
inside <pre></pre>
.
注意2: 关于子问题,您可以在此处
NOTE 2 : About sub-question u can find the answer : here
(Sub-Q:具有条件的多个<br />
实例)
(Sub-Q : multiple <br />
instances with condition)
这篇关于删除< br/>从< pre>内部</pre>标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!