Ah, interesting. I was unaware of the "replace all in selection" command on the Find menu. However, the "replace" button in the Find dialog seems to do something different from the "replace all in selection" command. The "replace" button seems to be "do the find once in the selection, and then replace the entire selection using the result of the first successful match". The explanation that the lookahead fails to match within the selection explains the behavior.
On 17/02/2012, at 04.12, Erik Neumann wrote:This is basically the same as http://lists.macromates.com/textmate/2011-September/032978.html
> "replace all" works for me too. Which makes me feel confident this is a bug and not a mistake on my part.
On 5 Sep 2011, at 05:06, Brandon M Fryslie wrote: > […] when I do Replace in Current Selection (shortcut or menu) nothing is replaced. […] My hunch says it has something to do with the negative lookbehind but I don't see any way in which I've used it incorrectly so I am stumped. > > Anyone have any suggestions or is this a bug? This is a bug / limitation: When you Replace in Selection and your regexp matches text _outside_ the selection (via look-around assertions) it will fail because it doesn’t have access to the text outside the selection. The only workaround is to ensure the stuff matched in the look-around assertion is also part of the selection when using Replace in Selection (or alternatively use Replace All).