The problem with what you have is that regexes are greedy by default, so that .* is going to eat up every character up to the last > on the line. To prevent this, you can use the ? modifier after the * quantifier:
Another problem with your original regex is that it would miss a tag that spanned more than one line. Fixing this problem is the purpose of the /s modifier above.s/(<body\s.*?>)/$1$newContent/is
But parsing HTML with regexes is unwise. Try something like HTML::Parser.
the lowliest monk
In reply to Re: Regular Expressions
by tlm
in thread Regular Expressions
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |