替换多个br标签

时间:2015-06-01 15:17:36

标签: regex vb.net

我有一些文字:

Production Manager.<br>Responsibilities: Manage operations with emphasis on optimizing productivity, quality and safety.<br>This position is responsible for<br>

</br><Br>assigned manufacturing area(s) and oversees all aspects of that area, including labor, production, yield, sanitation, etc.<br>within established budgeted cost parameters.<br>

我正在尝试编写连续替换三个br标记的正则表达式,并将其替换为两个br<br/><br/>

三个或更多br - s只能通过新行的空格来旋转。

br标记可以是:

<br> <br/> <br />

或大写。

例如:

<br><br><br>将替换为<br/><br/>

<BR><Br><br />将替换为<br/><br/>

<br /><BR/><br />将替换为<br/><br/>

<br><br><BR><br>将替换为<br/><br/>

我找到了这个链接:

How to Regex-replace multiple <br /> tags with one <br /> tag?

并尝试了这个:

/((<BR|<br)?\W?\/?(\s)>)/g

没有成功。

任何帮助表示赞赏!

1 个答案:

答案 0 :(得分:3)

如前所述,如果您的br代码具有属性,则可能需要使用HTML解析器。

试试这个正则表达式: float(x[3])

它将处理标签之间的空格和换行符。然而,属性是另一个故事。您可以修改正则表达式以允许sort=sorted(csv1,key=lambda x:float(x[3])) 标记内的任何字符,但可能存在一些问题。