Make regex more sensible, improve performance on long lines