ApiSandbox broken because of undefined variable

"TypeError: match is undefined". Ouch.

Also changed a regex a bit to avoid horrible backtracking.

Bug: 64047
Change-Id: Idf10ddfb0cca2d8c5fe91b8b5e582adba8b48824
(cherry picked from commit cdd5ef4812d99ac0274275e494ed8e7580c2e533)