On 24 Apr 2007, at 11:51, Jacob Rus wrote:
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})) (.*?)(?= *[,)])
OK. I see. Regarding to this problem I have a more general approach:
Two macros: SelectNextWord, SelectPrevWord (see attachments) (The keys are bound to CTRL+2 and CTRL+1, no scope)
With that you also can edit such a list (1, 22, 233 ) very easily and it works in any kind of text ;) If you in a word these macros select the current word
But still there is the more general topic of this thread:
The problem is that the current Find function doesn't select only the content of the regexp group '(.*?)', it also highlight the commas and brackets.
To write such lookahead/lookbehind regexp could be a bit tricky ;)
Hans