refactor($compile): simplify regular expressions

Closes #9637