Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Subpatterns in Grep?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
jmichel  
View profile  
 More options Oct 8 2012, 5:19 am
From: jmichel <jmi.mig...@gmail.com>
Date: Mon, 8 Oct 2012 02:19:38 -0700 (PDT)
Local: Mon, Oct 8 2012 5:19 am
Subject: Re: Subpatterns in Grep?

This sounds fine for my type of use.
Thanks again.

Le samedi 6 octobre 2012 17:04:43 UTC+2, Patrick Woolsey a écrit :

> To do this, just modify your existing pattern to find successive pairs of
> matching lines and combine their contents:

> Find:       (\d{6})(.+)(?:\r\1(.+))

> Replace:    \1\2\3

> and then repeatedly apply Replace All until all line pairs which start
> with
> the same numeric prefix have been consolidated to single lines.

> (E.g. for groups of 16 lines or fewer, this will take at most 4 passes of
> Replace All; for groups of 64 lines or fewer, 6 passes; etc.)

> PS: John Delacour's text filter is a much nicer general solution; the only
> advantage of the above is it doesn't require knowledge of Perl.

> Regards,

>  Patrick Woolsey
> ==
> Bare Bones Software, Inc.             <http://www.barebones.com/>

Le samedi 6 octobre 2012 17:04:43 UTC+2, Patrick Woolsey a écrit :

> At 23:50 -0700 10/05/2012, jmichel wrote:
> >Thanks for these explanations. They confirm what I suspected.
> >Assuming that the number of lines in one group can never exceed, say, 15
> >or so, could one circumvent the difficulty by explicitly repeating the
> >search pattern a sufficient number of times?

> Yes, and please see below.

> >Then the problem would be to ensure a match also in the case when the
> >number of lines is smaller. Any idea on how that could be achieved? Could
> >conditional matching help (I am not familiar with those "advanced
> >features")?

> To do this, just modify your existing pattern to find successive pairs of
> matching lines and combine their contents:

> Find:       (\d{6})(.+)(?:\r\1(.+))

> Replace:    \1\2\3

> and then repeatedly apply Replace All until all line pairs which start
> with
> the same numeric prefix have been consolidated to single lines.

> (E.g. for groups of 16 lines or fewer, this will take at most 4 passes of
> Replace All; for groups of 64 lines or fewer, 6 passes; etc.)

> PS: John Delacour's text filter is a much nicer general solution; the only
> advantage of the above is it doesn't require knowledge of Perl.

> Regards,

>  Patrick Woolsey
> ==
> Bare Bones Software, Inc.             <http://www.barebones.com/>

Le samedi 6 octobre 2012 17:04:43 UTC+2, Patrick Woolsey a écrit :

> At 23:50 -0700 10/05/2012, jmichel wrote:
> >Thanks for these explanations. They confirm what I suspected.
> >Assuming that the number of lines in one group can never exceed, say, 15
> >or so, could one circumvent the difficulty by explicitly repeating the
> >search pattern a sufficient number of times?

> Yes, and please see below.

> >Then the problem would be to ensure a match also in the case when the
> >number of lines is smaller. Any idea on how that could be achieved? Could
> >conditional matching help (I am not familiar with those "advanced
> >features")?

> To do this, just modify your existing pattern to find successive pairs of
> matching lines and combine their contents:

> Find:       (\d{6})(.+)(?:\r\1(.+))

> Replace:    \1\2\3

> and then repeatedly apply Replace All until all line pairs which start
> with
> the same numeric prefix have been consolidated to single lines.

> (E.g. for groups of 16 lines or fewer, this will take at most 4 passes of
> Replace All; for groups of 64 lines or fewer, 6 passes; etc.)

> PS: John Delacour's text filter is a much nicer general solution; the only
> advantage of the above is it doesn't require knowledge of Perl.

> Regards,

>  Patrick Woolsey
> ==
> Bare Bones Software, Inc.             <http://www.barebones.com/>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.