in reply to Regex won't match.

What am I doing wrong?

Hard to tell, since you didn't show us what you did. But I bet if you printed $TERMSDEF, you would have noticed it didn't contain what you'd hope it would contain because you didn't escape your slashes properly.