I want to verify if the code that enter is a HTML code ( is necessary to start with <html> and end with </html> )

I try to do this

var reghtml = new RegExp("(<html>*\n+</html>)");

but I have a problem is necessary to make a \n in the code, I need to verify the first and end tag ( = <html> and </html> ) and if he make something between them is necessary to start with < and end with >

Sorry, and if he make something between them is necessary to start with < and end with > is rather unclear.
– Wiktor StribiżewNov 26 '16 at 22:32

@WiktorStribiżew if he make like this <html></html> it's correct, but if he want to make something between the tag he need to start with < and end with >, for example <html> test </html> => error | <html> <test> </html> => correct
– saadsaadNov 26 '16 at 22:37

2 Answers
2

Here a pattern for you. It checks if the first level has a valid opening and closing tag. The first level has to have closing tags, you can't do <html><img /></html>, for that you can remove the whole closing tag checking pattern part.