align-regexp

align-regexp is an interactive autoloaded compiled Lisp function in `align.el'.


(align-regexp BEG END REGEXP &optional GROUP SPACING REPEAT)

Align the current region using an ad-hoc rule read from the minibuffer.
BEG and END mark the limits of the region. Interactively, this function
prompts for the regular expression REGEXP to align with.

For example, let's say you had a list of phone numbers, and wanted to
align them so that the opening parentheses would line up:

Fred (123) 456-7890
Alice (123) 456-7890
Mary-Anne (123) 456-7890
Joe (123) 456-7890

There is no predefined rule to handle this, but you could easily do it
using a REGEXP like "(". Interactively, all you would have to do is
to mark the region, call `align-regexp' and enter that regular expression.

REGEXP must contain at least one parenthesized subexpression, typically
whitespace of the form "\\(\\s-*\\)". In normal interactive use,
this is automatically added to the start of your regular expression after
you enter it. You only need to supply the characters to be lined up, and
any preceding whitespace is replaced.

If you specify a prefix argument (or use this function non-interactively),
you must enter the full regular expression, including the subexpression.
The function also then prompts for which subexpression parenthesis GROUP
(default 1) within REGEXP to modify, the amount of SPACING (default
`align-default-spacing') to use, and whether or not to REPEAT the rule
throughout the line.

See `align-rules-list' for more information about these options.

The non-interactive form of the previous example would look something like:
(align-regexp (point-min) (point-max) "\\(\\s-*\\)(")

This function is a nothing more than a small wrapper that helps you
construct a rule to pass to `align-region', which does the real work.