[TxMt] Re: possible format strings bug
matt at tidbits.com
Mon Apr 7 18:34:37 UTC 2014
On Apr 5, 2014, at 7:06 PM, Allan Odgaard <mailinglist at textmate.org> wrote:
> Contrast that to /(hey)?/. By adding ‘?’ after ‘(hey)’ we make that part of the regexp optional. This means the regexp will try to match “hey” (and put that in $1), but if there is no “hey” in the text, the regexp will still match (as we made this part optional), though nothing is captured in $1.
I have to fight my intuitions here. What I intuitively expect is that the Find/Replace dialog is a contract. If I say:
Then, since "hello" _is_ found, I expect that it will be replaced, in its entirety, by _something_: we DID find it so we WILL replace it. Thus, for example, I am surprised when this:
...yields "scramhello" in the document. The calculus in the replace expression has settled on the word "scram", which is what I was trying to achieve, but since what was originally found is "hello", I expect _all_ of "hello" to be replaced by "scram". In other words, I expect the replace expression to be a calculation about what to put in place of the whole text found by the Find expression. 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
More information about the textmate