Regexp optimization