[TxMt] Re: Search & replace regex question

Hans-Jörg Bibiko bibiko at eva.mpg.de
Tue Sep 2 15:53:24 UTC 2008


On 02.09.2008, at 17:35, Christian Bogen wrote:

> Hi everybody!
>
> Is there (in TextMate's built-in search) a solution for forming a  
> replace string for a variable directly followed by a number, ie. $15  
> (read: $1 and 5, without a space in between)?
>
> Can this somehow be done or is reformulating the search string the  
> only way in such a case?

Maybe you could try to use Conditional Insertions mentioned in the TM  
manual chapter 20.4.3
http://manual.macromates.com/en/regular_expressions

Naïve example:

I have the string

123456

and I want to get

123457

by using this regexp:

123(.)(.)7

this won't work:

123$1$27 because $27 isn't set

but this should work

123$1$2(?0:)7


(?0:) is a kind of dummy and inserts nothing


Cheers,

--Hans







More information about the textmate mailing list