> But regular expression, to be honest, is usually something I hardly think about performance.
This is actually not an uncommon problem. I recently experienced a backend system going down because of catastrophic backtracking. There is a reason why proper regex libraries have a timeout on the match methods.
For example: https://msdn.microsoft.com/en-us/library/hh160204(v=vs.110)....