[OS X TeX] Re: Find and replace with regular expressions
leingang at math.harvard.edu
Mon Nov 19 12:42:08 EST 2007
On Nov 19, 2007, at 12:23 PM, Art Werschulz wrote:
> On Nov 19, 2007, at 11:37 AM, Markus S wrote:
>> My poor man's way of doing is do a find all on '$'. Scan the list
>> if all equations have at least a space before the $ at the
>> beginning. If yes, do a find all for ' $', check again to see if
>> only equations in this list and then do replace all. Continue for
>> the end of the equations.
>> Or, categorise all occurances of '$'. If they are only of the type
>> \$ and $ equation $ then first replace \$ with something else that
>> is unique and use your regex. Finally, replace that unique string
>> with \$ again.
> Yet another idea: Use emacs, which has a query-replace-regexp
> command (which is normally bound to "C-M-%"). Type in a regexp
> that matches what you think describes your target, followed by its
> replacement text. For each regexp instance found, emacs will ask
> whether you really want to do the replacement.
TeXShop has this functionality, too. Once your search and replace
strings are set, click "Next", then "Replace & Find" if you want to
replace or "Next" again if you want to keep going.
You can also click the "Find All" button to see which strings match
your search string before replacing. When you're searching by
regexps it highlights not just the whole string but also the
substrings in separate colors.
One thing I never quite got about emacs regexps is they seem to
require quoted strings which means doubling all backslashes. Or am I
Preceptor in Mathematics
More information about the MacOSX-TeX