Re: reg exp help
Hi,
How can I make this:
foo( p1 , p2); bar(p3);
into
foo( p1 , p2);
bar(p3);
I tried
s/; bar/;\n bar
but that did not work.
You are not logged in. Please login or register.
Hi,
How can I make this:
foo( p1 , p2); bar(p3);
into
foo( p1 , p2);
bar(p3);
I tried
s/; bar/;\n bar
but that did not work.
In the replacement string, you need to use '\r' to introduce a newline. This should work then:
s/; bar/;\r bar
Although you probably don't want the space after '\r'.
Why \r? Historical reasons lost in the mists of time (vim does it this way).
thanks,
sooo vim regular expression are not standard regular expresion? ( if there is such thing).
The case above is not really a regular expression, it is actually the "replacement string" in the :s command. It supports a few special codes (& to repeat the whole match, \1..\9 to repeat the parenthesized submatches, \u \U \l \L to alter the case, \r to introduce a newline, etc...), but apart from that it's just a regular string.
But, indeed, there doesn't seem to be a "standard" regex format, really. The basic syntax of the original vi is standardized in POSIX, but the many extensions (in vim, in perl, etc...) are often different.
I implemented the regex engine in ViEmu from scratch, following vim's documentation to follow it as closely as possible. There are a few obscure features not implemented yet in my engine, but it's an almost complete reimplementation of vim's regular expressions.
Thanks,
Also I am trying to add a tab with \t but it does not work.
Kroiz, you're right, \t is missing there - I'll add it to the next build. In any case, you can just type it directly (the command line will show it as ^I, it's just the same thing).
cool thanks
You're very welcome!
Currently installed 3 official extensions. Copyright © 2003–2009 PunBB.
[ Generated in 0.027 seconds, 10 queries executed ]