On 2015-05-24 20:26, Meino.Cramer@gmx.de wrote:
> ...WHOW!.... (an then there was silence)....;)
>
> I am completly baffled...that such a simple task in vim "explodes"
> when one wants to do such a thing with sed. Which is a good
> argument for vim, indeed!
It's mostly a strong argument for a powerful regular-expression
engine. Sed's is pretty basic. I was hoping that Perl would make
it as simple as Vim, but apparently it doesn't support variable-length
look-behind like Vim:
$ perl -pi -e 's/(?<=^.{20,30})x/y/g'
Variable length lookbehind not implemented in regex
m/(?<=^.{20,30})x/ at -e line 1.
so you would have to use
$ perl -pi -e 's/(?<=.{20})(?<!.{30})x/y/g'
which is the generalized case of "there must be at least 20
characters before the match, but not more than 30 characters
before the match". It appears to work well for all the odd/degenrate
edge-cases I listed in my previous email. It's not as elegant as
the Vim version, but far better than the fragile sed version.
> Thank you very much for the help and of course the explanations
Glad to help!
-tim
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment