简体   繁体   English

正则表达式查找没有结束标记的锚标记?

[英]regex to find anchor tag which have not closing tag?

I am using the below regex to find anchor tag which have not closing tag but it is not working.我正在使用下面的正则表达式来查找没有结束标记但它不起作用的锚标记。 Only match which does not have closing tag.只匹配没有结束标签的。 can any provide the correct regex which would really works in this condition.任何人都可以提供在这种情况下真正有效的正确正则表达式。

Regex:正则表达式:

<a[^><]+\b(?!>) 

(It also selects the anchor tag which have closing tag) (它还选择具有结束标签的锚标签)

https://regex101.com/r/LbmI2G/1 https://regex101.com/r/LbmI2G/1

在此处输入图像描述

A bit more simplistic than Tim's but here's a basic idea:比蒂姆的更简单一点,但这里有一个基本的想法:

  1. Match on a < before a > , or:<之前匹配> ,或者:
  2. Match on no following >匹配没有关注>

<a[^><]+((?=<)|(?..*>))

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM