I am not sure what specifically is causing the regex to take such a long time to match, and the example is somewhat contrived, but this did happen to us when trying to get match info from a small list of google places. The problem in this case was easily avoided by using googles metadata but I can imagine that this can happen elsewhere:
https://codepen.io/jquense/pen/GRaKqwv