in reply to Re: Rename html page titles
in thread Rename html page titles
Somthing like this is a bit more robust and writes a backup just in case it destroys stuff ;-) The [^<] class works well for REs in HTML where you want to match potential multilines. There are of course edge cases where < could be valid content between tags. You deal with them with a forward lookahead ([^<]+|<(?!\s*/))* and alternation.
This sort of thing is a quick and dirty solution, the parsing modules or templating are better.
perl -pi.bak -e 's#<\s*title\s*>([^<]+|<(?!\s*/))*<\s*/\s*title\s*>#<t +itile>New Title</title>#i' <files> # this will correctly parse horrid stuff like <TiTle > One is < two more stuff </ title> <foo>bar</foo>
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|
|---|