[TxMt] Search and replace matching brackets?
robin.houston at gmail.com
Sun Sep 2 18:49:20 UTC 2007
Excellent, glad it was helpful.
It really ought to be possible to combine subexpression calls and back
references to do things like matching well-formed XML elements.
Unfortunately this doesn't work with the Onigurama engine, because
subexpression calls mess up back referencing. That's a real shame: it
does work in PCRE.
If you change \k<name> to \g<name> in the code below, then it will
work (but then of course it doesn't check that the closing tag has the
same name as the opening one).
(?x) # Enable layout and comments
# An XML name begins with a letter, underscore or colon:
# followed by a sequence of NameChars (see the XML definition):
# In XML, the whitespace chars are space, tab, CR and LF.
'[^']*' | "[^"]*"
[^<] # This is not quite technically correct, but is probably good enough
</ \k<name> \g<space>? >
< \g<name> \g<attr>* \g<space>? />
More information about the textmate