On 1. Jun 2007, at 02:34, Édouard Gilbert wrote:
While I'm at it, is there also a way to escape some commands in the same time ?
Typically, when I type
\lastname{Kant}'s life as a title, I'd like it to b converted to kant_s_life
But when I type \Z is the integer set (\where \Z is a macro to type Z in mathbf)
I'd rather like z_is_the_integer_set
Does anyone have an idea of some way to achieve that? I guess the first part should be too hard, but I'm far from being an expert in regexp.
Not entirely sure of the context -- this is a snippet regexp transformation?
Presumably something like this will do:
${1:your text} → ${1/\\w+{(.*?)}|\(.)|(\w+)|(\W+)/(?4:_:$1$2 $3)/g}
Here we match: a command of the form \command{«value»} or an escaped character of the form \«char» or multiple word characters or multiple non-word characters
If the last branch is taken, we insert an underscore, otherwise we insert the result of the other captures (we insert all 3, but since this is an OR, only one will actually have a value).