in reply to which loop is better

I once wondered this too. for and foreach seem to be exactly the same, so I think it's weird they behave different in your case.




"2b"||!"2b";$$_="the question"
Besides that, my code is untested unless stated otherwise.
One more: please review the article about regular expressions (do's and don'ts) I'm working on.