One useful tool I find in InDesign are the Grep styles. With them, one can define character styles (e.g., boldface in small caps) for whatever expression matches the grep pattern.
I know this is quite easy to statically carry this out with the help of most modern text editors — viz., searching for a regex pattern and replacing all matches with the desired code (e.g., {\bfseries\scshape. . .} or whatever).
But can this be done dynamically in LaTeX?
For instance, I would like to tell LaTeX something like the following:
\newregexstyle{^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$}{\bfseries\scshape}
so that all matching expressions (in this case, syntactically valid email addresses) are dynamically formatted in the desired manner. (Yes, I know — there would be a problem here with chars %, @, $ and the like. But this is just an example. The syntax should conform to l3regex's rules.)
The good thing about dynamically sorting this out is (1) that the coded text looks cleaner (and easier to edit), (2) that when writing the text I should care not for these expressions' styles, and (3) that I can easily change (or even remove) the format at any time without much editing. (I'm thinking here of complex documents with many \include and \input commands.)
\email{x@y.z}is the way to go in TeX and what makes for cleaner code. – egreg Oct 7 '12 at 21:45x@y.zseems to me cleaner than\email{x@y.z}, just as\email{...}does in comparison with{\bfseries\scshape...}. Be that as it may, I think my question is still worth considering. – NVaughan Oct 7 '12 at 21:54