by pietzcker » Wed Feb 18, 2009 3:12 pm
This is difficult with regular expressions, especially if you only want the nth ^ to be highlighted. It wouldn't be a problem to match everything up until the nth ^, but that isn't what you need, I guess. If Perl were to support variable-length lookbehind, it would be easy to do, but sadly, that's a feature Perl doesn't have.
I see two options:
Search for all the text leading up to the nth ^ using the Perl regex ^(?:[^\^]*\^){n-1}[^\^]* - then the cursor will be placed right before the nth ^. (Of course you have to replace n-1 by an actual number)
If you want to select the nth ^, you could use the approach above in combination with a macro:
InsertMode
ColumnModeOff
HexOff
Key HOME
PerlReOn
Find RegExp "^(?:[^\^]*\^){4}[^\^]*"
Key RIGHT ARROW
StartSelect
Key LEFT ARROW
to select the fifth ^ in this case.
A completely different idea:
You said that these are data delimited by ^. You could use the command "Convert to fixed columns" in the Column menu and specify ^ as the separator character. This will align all the separators throughout the file, ensuring that the nth ^ is always in the same column. Perhaps that's also a possibility?