Use a single regular expression instead of a for loop.