I've got several files that have double <body>
tags in them (either on purpose or by accident). I'm looking to find the first occurrence only of the <body>
tag and append it with additional HTML code. But the second occurrence shouldn't be affected. I'm using TextWrangler. The regex I'm using now replaces both occurrences rather than just the first.
Text:
<body someattribute=...>
existing content
<body onUnload=...>
RegEx I'm using:
Find: (\<body.*\>)
Replace with:
\n\1
appended HTML code
Current result:
<body someattribute=...>
appended HTML code
existing content
<body onUnload=...>
appended HTML code
So it's adding my appended code twice. I just want it to happen to the first <body...>
only.
...` is actually correct and will start the body at the location of the `
– Mr Lister Dec 21 '15 at 22:27`. Because the body's start tag is optional! So you get a `` inserted automatically. Therefore, the place where the body starts can NOT be determined with a regex that searches for `