Normalized handling of term values between string terms facet and terms stats facet

This gives the term stats facets the script, exclude and regex features. Closes #3004 and #2109.