0

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

enter image description here

Alan Moore
  • 73,866
  • 12
  • 100
  • 156
AMit SiNgh
  • 325
  • 4
  • 17
  • can u provide an example of a desirable output with example inputs? and also do not post images, copy and paste the code so people can reproduce it. – marcos Mar 23 '21 at 05:09
  • I want to match only below string also I have provided link above. – AMit SiNgh Mar 23 '21 at 05:11
  • 1
    Does this answer your question? [RegEx match open tags except XHTML self-contained tags](https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags) – knittl Mar 23 '21 at 05:12

1 Answers1

2

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[^><]+((?=<)|(?!.*>))

enter image description here

David542
  • 104,438
  • 178
  • 489
  • 842