[TxMt] possible format strings bug

Matt Neuburg matt at tidbits.com
Fri Apr 4 14:45:19 UTC 2014

I think I've found a bug in TextMate's regular expression format string replacement feature. Try this.

Target document:

=== testing
== testing
= testing

Find expression (regex):


Replace expression:


Do a replace all. What I expect:

2 testing
1 testing
0 testing

What I get:

2 testing
1 testing
1 testing

In the last line, neither group 2 nor group 1 should be matched, since the initial equal-sign is supposed to scarf up the entire match. Therefore I expect the logic to be:

* group 2 failed, so use its "else" alternative, which is the test for group 1

* group 1 failed, so use its "else" alternative, which is the value "0"

But try as I may, I cannot make "0" appear in the document. That is the proposed bug. It is as if group 1 is thought to be _always_ satisfied, which should not be the case.

Of course, feel free to prove me wrong by fixing my find/replace expressions, thus doing my homework for me. :) m.

matt neuburg, phd = http://www.apeth.net/matt/
pantes anthropoi tou eidenai oregontai phusei
Programming iOS 7! http://shop.oreilly.com/product/0636920031017.do
iOS 7 Fundamentals! http://shop.oreilly.com/product/0636920032465.do
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html

More information about the textmate mailing list