Fix regexp, period needs to be escaped. Use better exception handling.