Might be better to cache the regex because of the nested loops