The next 2 lines can probably be incorporated in a single regex. @simong or myself can probably help with the regex if it turns out to be problematic.