auto: fmap_aregex, rewrite functions to use that

This code does a few translations of characters in a regular expression,
with more to come. Pull out the recursive pattern to fmap_aregex.