Small cleanups to regex.

 * use extended syntax
 * clean up docs
 * remove non-capturing subpatterns
 * wrap some lines better