Searching for lines with different numbers

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Searching for lines with different numbers

meino.cramer

Hi,

I have a logfiles (Gentoo: 'qcheck -a' ), which contains lines like:

Checking dev-lua/luasocket-3.0_rc1-r3 ...
  * 69 out of 69 files are good

Lines contains "<number_a> out of <number_b> files are good"

Is it possible to find all lines, where "<number_a>" differs from
"<number_b>" ? Does work backrefrences here?

Best regards,
mcc



--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Searching for lines with different numbers

Ethan Hereth
Hi mcc,

On Sat, Mar 14, 2015 at 12:37 AM, <[hidden email]> wrote:

Hi,

I have a logfiles (Gentoo: 'qcheck -a' ), which contains lines like:

Checking dev-lua/luasocket-3.0_rc1-r3 ...
  * 69 out of 69 files are good

Lines contains "<number_a> out of <number_b> files are good"

Is it possible to find all lines, where "<number_a>" differs from
"<number_b>" ? Does work backrefrences here?

I was able to find the lines in question with the following search

/\(.\) out of \1\@!.*files match 

Here, \@! makes sure that \1 (which refers to the \(.\) capturing group that contains the first number found) does not match at that position.

Does this work for you?

Ethan Alan


Best regards,
mcc



--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Searching for lines with different numbers

meino.cramer

Hi Ethan,

thanks fpor your reply ! :)

...it does nearly work...;)

The first part of the expression only catches one digit and
compares this to the digits of the second number, which
is different most of the time...

Best regards,
mcc




Ethan Hereth <[hidden email]> [15-03-14 06:40]:

> Hi mcc,
>
> On Sat, Mar 14, 2015 at 12:37 AM, <[hidden email]> wrote:
>
> >
> > Hi,
> >
> > I have a logfiles (Gentoo: 'qcheck -a' ), which contains lines like:
> >
> > Checking dev-lua/luasocket-3.0_rc1-r3 ...
> >   * 69 out of 69 files are good
> >
> > Lines contains "<number_a> out of <number_b> files are good"
> >
> > Is it possible to find all lines, where "<number_a>" differs from
> > "<number_b>" ? Does work backrefrences here?
> >
>
> I was able to find the lines in question with the following search
>
> /\(.\) out of \1\@!.*files match
>
> Here, \@! makes sure that \1 (which refers to the \(.\) capturing group
> that contains the first number found) does not match at that position.
>
> Does this work for you?
>
> Ethan Alan
>
>
> > Best regards,
> > mcc
> >
> >
> >
> > --
> > --
> > 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 [hidden email].
> > For more options, visit https://groups.google.com/d/optout.
> >
>
> --
> --
> 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 [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Searching for lines with different numbers

LCD 47
On 14 March 2015, <[hidden email]> wrote:

>
> Hi Ethan,
>
> thanks fpor your reply ! :)
>
> ...it does nearly work...;)
>
> The first part of the expression only catches one digit and compares
> this to the digits of the second number, which is different most of
> the time...
[...]

    It's easy to make the pattern safer:

        /\m\<\(\d\+\) out of \%(\1\)\@!\d\+ files

    /lcd

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Searching for lines with different numbers

Tim Chase
In reply to this post by meino.cramer
On 2015-03-14 07:53, [hidden email] wrote:

>
> Hi Ethan,
>
> thanks fpor your reply ! :)
>
> ...it does nearly work...;)
>
> The first part of the expression only catches one digit and
> compares this to the digits of the second number, which
> is different most of the time...

/\<\(\d\+\) out of \%(\1\>\)\@!\d\+ files are good/

should catch the cases where the first one is a substring of the
second one, or the second one is a substring of the first one.

I don't know if it's smart enough to change the text in the event of
1 file to read "1 file is good" in which case you'd need to have that
alternative.

 /\<\(\d\+\) out of \%(\1\>\)\@!\d\+ file\%(s are\| is\) good


-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 [hidden email].
For more options, visit https://groups.google.com/d/optout.