> I am curious whether this kind of meta-regexp is
> possible with vim:
> I want to match a certain kind of pattern and want to
> do "something" with it.
> The kind of pattern does not describe a group of chars
> but their relation to each other.
> I want to search for a number sequence like
> and also
> and also
> and also....
> I want to find a sequence of five identical characters. The
> character itsself doesn't matter.
I think the best "recipe" is knowing the ins and outs of Vim's
regexp syntax. It's possible to describe all the cases you
describe using "\(...\)" tagging and back-references, depending
on the flexibility of your description. However, there's no
meta-character syntax for sequence-ness. Thus, it's easy to find
digitA digitB digitB digitA
but considerably more complex to find
digitA digitA+1 digitA+1 digitA
where the 2nd/3rd characters are algorithmically related to the
1st/4th characters. There are also edge cases about "what should
X be for '9XX9'". If it was sufficiently complex to find
something like this, I'd build the regexp with something like
:while (i<9)| let x=x.i.(i+1).(i+1).i.'\|' | endwhile
which would yield something like
in register "x" which could then be dumped into a search using
control+R followed by "x". One might even do the above algorithm
directly on "@/" rather than on x.
For your second case, it's as easy as
(that's a digit "one" not a letter "ell" or "eye")
For your first case, I've occasionally thought it would be quite
handy to have an expression-register in the search as well as in
the replacement (akin to the "\=" in the replacement) that could
operate with access to its context, something like
using an imaginary \=() syntax for expressions. I haven't
thought long and hard about it; I don't know if it would have
horrible performance; I don't know if it would have other
breakages. But it would be darn powerful. :)
The above would use '9009' as without the modulus ("%"), it would
search for "910109"
Alas, no such atrocity exists yet, though you can bet that if it
did show up, I'd be abusing it left and right :*)