Count the number of the substring matched by the regular expression.