Does anyone have any idea why this regular expression is causing my application to hang?
/^(?:((?:.+?)(?: of the )?)+) of the (?:(.+?)) (?:"(.+?)")$/
It hangs when I try to use it to match strings like this:
'description of the post "This is a Post"'
But it seems to happen pretty fast when I use it to match a shorter string like this:
'age of the person "Bob"'
Any ideas on why this is happening or how I can fix it?
This is the result of catastrophic backtracking in your regular expression, the following portion of your regex is likely the culprit:
You should try to refactor your regular expression any time you have nested repetition. In this case I think you can simplify that entire portion to
.+and have your regex behave the same way.