Reputation: 23052
I want to match any sequence of letters with some other special characters, say :
and ;
. Here's what I've tried to do:
/[\w;:]*
But this just seems to match everything. The VIM documentation gives [Vv]
as an example for a regexp that can locate either V
or v
, and sure enough this seems to work. What am I doing wrong here?
Upvotes: 0
Views: 617
Reputation: 172590
The \w
atom doesn't work inside a collection. You need to either use branches:
/\%(\w\|[;:]\)*
but it's easier to look up the character ranges via :help /\w
and put those into the collection:
/[0-9A-Za-z_;:]*
There are also several character classes; there's none for \w
, but [:alnum:]
comes close, missing only the _
:
/[[:alnum:]_;:]*
Note: If you really just want letters, that would be \a
or [:alpha:]
.
Upvotes: 1
Reputation: 174706
to match any sequence of letters with some other special characters, say : and ;
[A-Za-z:;]*
\w
not only includes letters but also digits and underscore symbol. *
repeats the previous token zero or more times.
Upvotes: 1