regex: remove the use of ~[] & some unnecessary ~'s.

The AST doesn't need ~s everywhere, so we can save allocations this way
& the enum isn't particularly large (~4 words) nor are regexes
long (normally), so the space saved in the `Cat` vector is unlikely to
be very much.
regex: General style tweaks.

For loops are nicer than manual whiles, etc.
auto merge of #13863 : huonw/rust/re-tweaks, r=pcwalton

Mostly code style e.g. avoiding `~` and using `for` + iterators.