用于匹配文本htmltag文本htmltag模式的Regex

Regex for matching a text htmltag text htmltag pattern

本文关键字:htmltag 文本 Regex 模式 用于      更新时间:2023-09-26

我该如何定义一个正则表达式来获得这样的模式

text HTML标记text HTML标记文本HTML标记。。。。。。。。

基本上,单元模式是"文本HTMLTag",可以使用$1和$2获取。

一个exmaple数据将是

abarelixx is a sample data for spellchecking<img src="Randomz" alt="Randomz Image">Randomz is the name of the image</img>Bigboss<img src="Randomz" alt="Randomz Image">Randomz is the name of the image</img>this is another text string

这需要分解为文本HTMLTag。。。如果没有text/HTMLTag,它应该返回"。

我为这个问题找到了一个不错的解决方案。将'>'附加到开头并'<'直到最后。然后使用类似re=/([>])([^<]+)([<])/g$2的模式将是所有的文本内容。当然,您可以使用普通的HTML模式来获取HTML标记。