Improved regex matching.