Improve regex by a suggestion from csteipp.