On 2013-09-15 14:23, Steve wrote:
> IP mm/dd/yy hh:mm
>
> with IP being an standard IP address. This file is being populated
> by a script which basically gets the IP and writes it at the end of
> the file. But sometimes, this fails and I get a line with only the
> date and time. My goal is to rid of these lines.
>
> I tried something like:
>
> :g!/^([0-9]{1,3}.)3.([0-9]{1,3})/d
>
> but it erases the whole file. I know that this regexp is not
> perfect (it will also catch 999.999.999.999, which isn't a valid IP
> address), but that doesn't seem to be the problem here.
As long as you're okay with the 999.999.999.999 being considered
kosher, and skipping IPv6 addresses, you should be able to use
:v/^\%(\d\{1,3\}\.\)\{3\}\d\{1,3\}/d
that would be
:v/ On every line that doesn't match the following
^ at the start-of-line
\%( a non-capturing group
\d\{1,3\} 1-3 digits
\. followed by a literal period
\) the close of the group
\{3\} that group 3x (the first 3 quads)
\d\{1,3\} another set of 1-3 digits (the last quad)
/d delete them
-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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.