Hi Guys,
I'm in need of regular expression for validating the html tags
that are closed properly,
say for example
<i>test content <b>see this </i> ..
it should show an alert "tag is incorrect".
Plz help me....Guys-:)-:)
Thanks in advance
Hi Guys,
I'm in need of regular expression for validating the html tags
that are closed properly,
say for example
<i>test content <b>see this </i> ..
it should show an alert "tag is incorrect".
Plz help me....Guys-:)-:)
Thanks in advance
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.
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.
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:-/
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".
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.