[TxMt] [ANN] Select Balanced HTML Tag!!!1!

Thomas Aylott - subtleGradient textmate at subtleGradient.com
Fri Nov 16 17:51:10 UTC 2007


On Nov 16, 2007, at 12:30 PM, Alex Ross wrote:

> I don't mean to get all nerdy on you guys but the problem that  
> you're running into here is that HTML is context-free.  Regular  
> expressions can't match context free languages.  There are  
> mathematical proofs of this... so what you're trying to do is really  
> truly impossible.
>
> What you need is someway to remember some state, which is the  
> counter that Hans mentioned or a transformation of the tags so that  
> each has a unique (ordered) identifier.  Also, you can match it if  
> you have the recursive subexpression from Oniguruma.  But you  
> don't.  My uh... suggestion is to give up using plain-old regular  
> expressions :).  It can never work.
>
> –Alex

Hey, thanks. But duh ;)
	that's why the macro I just released actually works.
	I gave up on regex finally and mangled HTML around a bit to work with  
the normal select brackets internal TextMate command.

I was fiddling around with recursive regex, but it seems to completely  
crash TextMate if you don't have it just right, so it's extremely hard  
to play with.

—Thomas Aylott – subtleGradient—


More information about the textmate mailing list