[texworks] Search and replace using regex

Joseph Wright joseph.wright at morningstar2.co.uk
Sun Aug 22 00:19:34 CEST 2010


On 21/08/2010 18:25, Joseph Wright wrote:
> Hello all,
>
> I'm continuing with my attempts to get to grips with regex searching. I
> think I understand the search part of the system as implemented in
> TeXworks, but am stuck with the replace part. For example, I recently
> wanted to search for
>
> \\(?:\w+)\s+\\tex_(?:\w+):D
>
> (for some LaTeX3 stuff) and replace it with the expression
>
> \\tex_\2:D \\\1
>
> i.e. with the two command sequences interchanged. However, I just get
> literal '\1' and '\2' as replacements when I try this (the search itself
> is fine). Is there a way to get the matched groups from the search in
> the replace part?

Answering my own quesion, it seems I needed the search term to read

   \\(\w+)\s+\\tex_(\w+):D

You live and learn.
-- 
Joseph Wright


More information about the texworks mailing list