Java regex to retain specific closing tags -


I'm trying to write a regex to remove everyone, but some free xml tags are off for free

The code looks quite simple:

  string stringopers = "body">  

However, when it runs, it excludes the "xml" closing tag, leaving any tag where the compiled group (a | mam | li) is a matching character That means if I remove "L" from "Li", then it works.

I hope this will return the following string: " gt; & lt; xml & gt; some stuff " (I Extra parsing to remove the opening tag, but for example it). You probably should not use regex for this task but see what happens. .

Your problem is that you are using a negative character class, and inside character classes you can not write complex expressions - only characters you can try a negative lookup instead: < / P>

  "& lt; / (?! A | AM | Lee). *? & Gt;"  

But it will not handle many cases correctly:

  • Comments appearing like tags.
  • Tag
  • Capital letters.
  • Tag

You might be able to fix these problems, but you should consider this Whether it's worth it or not, or it would be better to find the solution based on the appropriate HTML parser.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -