[TxMt] Re: TM Find Dialog Enhancement (?)
Jacob Rus
jacobolus at gmail.com
Tue Apr 24 09:51:36 UTC 2007
Hans-Joerg Bibiko wrote:
> Would it be possible to add the following feature to the normal Find
> dialog?
>
> Given a string "c( 1, 22, 333 , 4444 )" in a line.
> I want to highlight item by item ('1', '22', etc.) by using the normal
> Find function (APPLE+G).
>
> To do so I would write for instance this regexp:
> [,\(] {0,}(.*?) {0,}[,\)]
You can use lookahead and lookbehind. So you could do:
(?<=[,(] )(.*?)(?= *[,)])
The only problem with this is that lookbehind can't handle
variable-length patterns, so you can't quite manage the pattern you
have, with any number of spaces before the item. But if you want, you
can make it handle 1-4 spaces, or something, as follows:
(?:(?<=[,(] )|(?<=[,(] {2})|(?<=[,(] {3})|(?<=[,(] {4}))
(.*?)(?= *[,)])
Or similar.
See the documentation for more. Oniguruma regexps are very powerful.
-Jacob
More information about the textmate
mailing list