I have a quick question about the regex (neo)vim uses. After long hours of toiling, staring at documentation and trying everything else I could think of, I seem to be stuck.
What I'm trying to accomplish is this:
I'm working on updating the d.vim file, as there hasn't been an update to it since 2016 (AFAIK, anyways), and I don't know about you, but proper syntax highlighting is one of the great pleasures in my life.
I've been able to brute force vim regex in to my brain to figure out how to match everything I've wanted to up to this point, that point being trying to match the namespace of a function. For example, say I have the following chunk code:
void main() {
int i = 10;
i += 2;
std.writeln(i);
}
The thing I want to return is specifically:
std
To accomplish this, and after (admittedly many hours of) trial and error, I've come up with the following chunk of regex:
\v((^\W{-})@<=\w+)\@=(\.)
Which returns:
std.
While I want it to only return:
std
I've searched high and low, far and wide, and yet come up empty handed. Is it possible to do this? Is there some way to trim the last character off of the end of a regex match? Please teach me, a mere novice, the ways of the RegEx!
Side question that doesn't take priority: I did manage to figure out a string in regular regex that would return what I'm looking for:
(?<=\s)\w+?(?=\.)
My totally-2nd-priority-question here would be: Is there some "easy" way to convert between "regular" regex and vim regex?
Thanks!
[ EDIT: Grammar 'n stuff ]
\%(\%(^\s\+\)\@<=\w\+\)\ze\.
?:h perl-patterns
.