so that I get:
["/home/emmanuel", “/”, “/home/emmanuel/my\ dir\ with\ spaces”]
that means that I want to split by spaces that are not preceded by a “\”.
If I had the perl regexp, I would type:
string.split %r{(?<!\) }
but here I get a compile error and admitedly this is not documented in the
pickaxe book.
any idea?
emmanuel
PS: the vim doc for this pattern:
@<! Matches with zero width if the preceding atom does NOT match just
before what follows. Thus this matches if there is no position in the
current or previous line where the atom matches such that it ends just
before what follows. |/zero-width| {not in Vi}
Like '(?<!pattern)" in Perl, but Vim allows non-fixed-width patterns.
The match with the preceding atom is made to end just before the match
with what follows, thus an atom that ends in "." will work.
Warning: This can be slow (because many positions need to be checked
for a match).
Example matches ~
(foo)@<!bar any “bar” that’s not in “foobar”
(//.)@<!in “in” which is not after “//”
I’m looking for the pattern which is (?<!pattern) in perl and @<! in vim
for ruby, but it seems not to exist (while some other (?:), (?=) (?!)
sequences do exist).
Currently, lookbehind is not implemented. Oniguruma RE engine
has it and will be used in future.
Any alternatives? Does it actually exist?
What i would like to do: split this string:
“/home/emmanuel / /home/emmanuel/my\ dir\ with\ spaces”
so that I get:
[“/home/emmanuel”, “/”, “/home/emmanuel/my\ dir\ with\ spaces”]
string.scan(/(?:\ |[^ ])+/)
···
At Sun, 8 Dec 2002 00:43:06 +0900, Emmanuel Touzery wrote: