Move preg_match() that should only run once out of the loop.

props dllh.
fixes #28575.

git-svn-id: https://develop.svn.wordpress.org/trunk@28776 602fd350-edb4-49c9-b593-d223f7449a82