[TxMt] Re: Search & replace regex question
Patrick James
pj002 at mac.com
Tue Sep 2 19:40:52 UTC 2008
Hi
That is a very useful thing to know about. It does strike me as very
strange that the Oniguruma Regular Expressions system is like this.
I haven't as yet encountered a situation where this was going to be a
problem but I'd noticed that it doesn't seem to be accounted for in
Oniguruma.
In the system used by BBEedit¹ the matching expression is two or three
characters long, where the last one or two characters or digits.
So, \1 matches the first group in the find expression and \01 does the
same. If you want to replace this followed by the digit "2" then you
put \012 in the replace expression. This is no problem up until 99
matches of course :)
¹Apologies for mentioning BBEdit :)
Patrick
http://www.patrickjames.co.uk
On 2 Sep 2008, at 16:53, Hans-Jörg Bibiko wrote:
> 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
More information about the textmate
mailing list