http://qs321.pair.com?node_id=406654


in reply to Non-greedy regex behaves greedily

Because you insist on a character after 'body' that isn't there when you use '.+?'.

Change it to s/<body.*?>/<body class="theBody">/ and it will work.