http://www.perlmonks.org?node_id=557290


in reply to regex incorrectly matching newline

The regex is not matching the "\n", it succeeds by matching the 'h' of "hello\nthere". Furthermore, even if you make the \n as the first character of $i, by setting $i = "\nthere", the regex will continue to succeed because it will matches the 't'.