[OS X TeX] Re: Find and replace with regular expressions
agw at comcast.net
Mon Nov 19 12:23:36 EST 2007
On Nov 19, 2007, at 11:37 AM, Markus S wrote:
>> Indeed, my original response pointed out that very flaw, and
>> others. But I wanted to give an answer which would probably work
>> for a lot of the document, and if he wanted to (learn enough to)
>> tweak the regex he could, or just find the rest manually, he'd
>> still save a lot of work.
>> Is there any regex that's going to work 100% of the time?. How
>> would you fix the text
>> Acme sells widgets for \$5.00 a unit. The cost to produce $x$
>> widgets is $\$(2x-0.03 x^2)$.
> 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.
207 Stoughton Avenue, Cranford NJ 07016-2838
More information about the MacOSX-TeX