Regex用于选择一个标签,它的旁边包含没有任何空格的文本


regex to select a tag and which contains text beside it without any space

这是文本

Tutorial<del class="del">Within word</del>WordEnd sample <del class="del">total word</del> Welcome to the site!

我试图写正则表达式来选择标签<del><del></del>之间的任何东西,以及它旁边的文本,但只选择那些<del>标签,标签和前面的文本之间没有空间。

例如在上面的文本中- Tutorial<del class="del">Within word</del>WordEnd必须被选中。但是<del class="del">total word</del> Welcome不能被选中,因为在和Welcome之间有一个空格。

谁来帮帮我。提前感谢!!

最后一次尝试:

"/('w+<del.*?>.*?(<'/del>'w+|<'/del>))|(<del.*?>.*?<'/del>'w+)/g"
https://regex101.com/r/mD8zF7/10

我想这就是你要找的:

/([^'s]+)('<del)(.*?)('<'/del'>)([^'s]+)/

示例:https://regex101.com/r/sL8jV8/1

如果你在一个字符串中寻找多个匹配(上面只是1),使用这个:

/([^'s]+)('<del)(.*?)('<'/del'>)([^'s]+)/g

示例:https://regex101.com/r/hE6dH4/1