On Sep 15, 2013 4:23 PM, "Steve" <[email protected]> wrote:
>
>   Hi,
>
>   I have a text file with more than 300K lines in it which I would like
> to clean. Each line is of the form:
>
> 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.

In vim this catches opening parenthesis at the start of the line followed
by a digit followed by an opening figure brace, 1, comma, 3, closing figure
brace, any character, closing parenthesis, 3, any character, opening
parenthesis, digit, opening figure brace, 1, comma, 3, closing figure
brace, closing parenthesis. Obviously you do not have such lines in a file.

Note that it is not a regex for IPv4 address in any regex engine I know
about: e.g. (...)3 is capturing group followed by 3 in PCRE, dot represents
any character, not only the dot itself, in all of PCRE, BRE, ERE, vim.

Check out :h regex for the correct syntax.

>   What's wrong?
>
>   Thanks for any tips.
>
>   Best,
>   steve
>
>
> --
> --
> 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.

-- 
-- 
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.

Reply via email to