[OS X TeX] Replace \f{x} by \g{x}\h{x}

Andrew Miller ajmiller at engr.psu.edu
Fri May 1 17:35:02 CEST 2015


> On May 1, 2015, at 10:43 AM, Alain Schremmer <schremmer.alain at gmail.com> wrote:
> 
> 
> On May 1, 2015, at 9:54 AM, Andrew Miller wrote:
> 
>> If you want to replace \f{stuff} with \g{stuff}\h{stuff} and \f{other stuff} with \g{other stuff}\h{other stuff} you could use find and replace in BBEdit or TextWrangler with Grep where the search string is a regex pattern:
>> 
>> \\f\{([^\}]*)\}
>> 
>> and the replacement is
>> 
>> \\g{\1}\\h{\1}
>> 
>> The pattern ([^\}]*) captures the content inside the curly braces and the \1 pastes it in your \g and \h commands.
>> 
>> Grep needs to be checked in the Find dialog for this to work.
> 
> (1) I duly noted that my question was ill-posed.
> 
> (2) TextWrangler did what you said and, of course, it did exactly what I wanted.
> 
> (3) My question remains: would you know of a tutorial that this grep-challenged person could learn from instead of asking off-topic questions? (Not that I do not appreciate not having to learn grep.)
> 
> (4) In any case, this (old) person is immensely grateful for the very large amount of time he will be saving using this grep and Multi-File Search to correct something idiotic he did repeatedly across many long files.
> 
> Very best regards,
> —schremmer

Whenever I have a question on regular expressions or grep I usually look through:
http://www.regular-expressions.info/ <http://www.regular-expressions.info/> 
There are tutorials, examples and reference info.

—Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/macostex-archives/attachments/20150501/46bdd59f/attachment.html>


More information about the macostex-archives mailing list