I would have to defer to the regular expression experts, but VIM does not use the standard regular expressions that work on
the command line, in say, Linux. Specifically, in the example
cited, '/s' was used for whitespace matching, which is not available in standard regular expressions (c.f. GNU regular expression implementation).


The phrase "standard regular expressions" is a bit of a misnomer.
There are posix regexps which are well defined.  However, they
are also fairly limited in comparison to the extensions of
various RE engines.  You'll find subtle differences in the regexp
engines as you migrate from a standard POSIX compliant regexp
engine (where you beat your head as you reach for helpful
shorthand notations you use elsewhere) to

-Perl
-Python
-PHP
-Vim (and nvi, elvis, etc)
-Bash
-grep/egrep/fgrep
-various flavors of Sed
-"regular expressions" in Visual Studio [*]

Each has their own nuances, plusses and minuses, as well as
potential additional integration with their environment.  Even
within vim, you have various degrees of 'magic'ness available to
you.  Fortunately, once one has learned what is "usually"
possible in a most regexp engines, it's just a matter of learning
the engine-specific syntax for what you want.  I love vim regexps
for their power, but like some of the cleaner syntax available in
PCREs that you get in Perl and its cousin Python (and other places).

Per your whitespace comment, the POSIX atom would be

        [[:blank:]]

or

        [[:space:]]

depending on whether you want to consider newlines...POSIX (last
I understood it) doesn't use the "\w" or "\s" notation for
whitespace.

-tim

[*] I hesitate to call these regular-expressions as the last time
I tried them, they were more like "wildcards with a few extra
metacharacters" or "regular-expressions with their knees bashed
in" than real regular-expressions.




Reply via email to