I'm trying to make a regex to add <body>, </body> and </html> tags, wherever they are missing.
maybe this will work.
Code:
(</head>\s*)(<body>)?([^(</(body|html)>)]+).*
replace with
Code:
\1<body>\3</body></html>
is there a simpler and more reliable regex, like
Code:
(</head>\s*)(<body>)?(.+)(</body>)?^^extra greedy^^\s?(</html>)?^^extra greedy^^
replace with
Code:
\1<body>\3</body></html>
to give one "?" first priority to be greedy, before a previous "?".
edit
is at least the first regex valid and reliable?