[TxMt] Re: Select and Replace: magic needed....

Nicholas Cole nicholas.cole at gmail.com
Mon Jun 15 22:43:35 UTC 2009


On Mon, Jun 15, 2009 at 8:01 PM, Alex Ross<tm-alex at rosiba.com> wrote:
> On Jun 15, 2009, at 11:45 AM, Nicholas Cole wrote:
>
>> On Mon, Jun 15, 2009 at 7:24 PM, Scott Haneda<talklists at newgeo.com>
>> wrote:
>>> On Jun 15, 2009, at 11:11 AM, Nicholas Cole <nicholas.cole at gmail.com>
>>
>>> Curious... Is your desired text to change always structured the same?
>>>
>>> Why not use a regex based find and replace and connect that to a hot
>>> key via a bundle?
>>
>> The problem with a regex is that the British use of single quotes
>> makes apostrophes confusing.
>>
>> So:
>>
>>> This is `some of Jefferson's text'
>>
>> Needs to become:
>>
>>> This is \enquote{some of Jefferson's text}
>>
>> I think only a human can get that right reliably.
>
> You need smarter regex's :)
>
> How about:
>
> `(.*?)'(?!s)
>
> So it starts by matching `, and matches until it finds a single ' that
> is not followed by “s”.
>
> Now you can replace this with
>
> \enquote{$1}

Dear Alex,

I will admit that is very, very cunning.  Unfortunately, there is one
other convention that messes it up, which is that some (especially
classical) possessives are in the form Socrates'.  Still, they are
rare and that does make that regex useful!

Best,

N.



More information about the textmate mailing list