3
Contributors
4
Replies
6
Views
7 Years
Discussion Span
Last Post by fxm
0

I doubt this is possible by only using a regular expression. There are so many levels of nesting possible, I think you would need a parser instead.

0

It is relatively easy to detect a <tagx> which is followed by <tagy> before </tagx> is encountered, but that may not be an error.

Trivial counter-examples include <b>xxx<br></b> and <b>xxx<br /></b> and there is an endless supply of not so trivial cases.

It would be possible to test certain tags; beyond that the reply about needing a parser is on point.

0

I doubt this is possible by only using a regular expression. There are so many levels of nesting possible, I think you would need a parser instead.

Pritaeas, you are right,it is possible by regular expression,I found the solution in php way it uses preg_match_all but i'm in need of alternative for it in java script.which should validate <b>,<i>,<u> tags that are closed properly or not.
Thanks:-/

Edited by mohanrajit.88: n/a

0

Javescript RegExp will do _precisely_ what preg_match does.
Neither will solve the general problem, and even the three cases you have now given will not be easy.
Part of the difficulty is that "closed properly" != "closed".

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.