Added a try catch to make regex matching safer