[texworks] Regex replacement

Jonathan Kew jfkthame at googlemail.com
Thu Apr 2 22:17:39 CEST 2009


On 2 Apr 2009, at 21:01, Joseph Wright wrote:

> Hello all,
>
> I'm trying to get a regex search-and-replace working, but can't seem  
> to
> find the correct incantation to keep the matched text.  For example:
>
> \\newcommand\*\{\\(?:[A-Za-z@]+|.)\}
>
> will match \newcommand* with @ as a letter, and I'd like to be able  
> to do:
>
> \newcommand*{\SomeMacro} => \newcommand*\SomeMacro
>
> However, thus far everything I've tried fails.  Any ideas?

\1 .. \9 in the replacement will yield the 1st to 9th parenthesized  
subexpression. So

    Replace:  \\newcommand\*\{(\\[A-Za-z@]+|.)\}
    With:     \\newcommand*\1

should do what you describe.

JK



More information about the texworks mailing list