Fixes #1 by modifying regex to cope with new lines in the text (http://stackoverflow.com/questions/1068280/javascript-regex-multiline-flag-doesnt-work)