Improved more on catching different regex error cases.