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
Greppng
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
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
 
LuKreme  
View profile  
 More options Oct 31 2012, 12:40 pm
From: LuKreme <krem...@kreme.com>
Date: Wed, 31 Oct 2012 10:40:21 -0600
Local: Wed, Oct 31 2012 12:40 pm
Subject: Greppng
I want to grep for words in a file that contain 'a' 'b' and 'c' in any order. I also want to find words that contain two c's, even if not together (so access and chance).

I might even want words with two c's AND a and b, again in any order.

I feel like I am forgetting something basic.


 
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.
Andrew Brown  
View profile  
 More options Oct 31 2012, 2:29 pm
From: Andrew Brown <li...@c18.net>
Date: Wed, 31 Oct 2012 19:29:05 +0100
Local: Wed, Oct 31 2012 2:29 pm
Subject: Re: Greppng
On 31 oct. 2012, at 17:40, LuKreme wrote:

> I want to grep for words in a file that contain 'a' 'b' and 'c' in any order. I also want to find words that contain two c's, even if not together (so access and chance).

> I might even want words with two c's AND a and b, again in any order.

Are you quite sure you want to do that?

AB


 
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.
John Delacour  
View profile  
 More options Oct 31 2012, 5:27 pm
From: John Delacour <johndelac...@gmail.com>
Date: Wed, 31 Oct 2012 21:27:11 +0000
Local: Wed, Oct 31 2012 5:27 pm
Subject: Re: Greppng
On 31/10/2012 16:40, LuKreme wrote:

> I want to grep for words in a file that contain 'a' 'b' and 'c' in any order. I also want to find words that contain two c's, even if not together (so access and chance).

> I might even want words with two c's AND a and b, again in any order.

> I feel like I am forgetting something basic.

As for most of these things, as text filter is the best solution. This:

#! /usr/bin/perl
use strict;
while (<>) {
     print;
     my @hits;
     my @words = split /\b/, $_;
     for (@words) {
         push @hits, $_ if /a/i and /b/i and /c/i or /c.*c/i;
     }
     printf "• Found: %s\n", join ", ", @hits if @hits;
     undef @hits;

}

will turn
     The accountant sat in the back of the
     cab wearing a black cocked hat
into
     The accountant sat in the back of the
     • Found: accountant, back
     cab wearing a black cocked hat
     • Found: cab, black, cocked

JD


 
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.
Ronald J Kimball  
View profile  
 More options Nov 1 2012, 12:47 pm
From: Ronald J Kimball <r...@tamias.net>
Date: Thu, 1 Nov 2012 12:47:52 -0400
Local: Thurs, Nov 1 2012 12:47 pm
Subject: Re: Greppng

On Wed, Oct 31, 2012 at 10:40:21AM -0600, LuKreme wrote:
> I want to grep for words in a file that contain 'a' 'b' and 'c' in any order. I also want to find words that contain two c's, even if not together (so access and chance).

> I might even want words with two c's AND a and b, again in any order.

> I feel like I am forgetting something basic.

True regular expressions are not well-suited to finding substrings in
arbitrary order.  However, you could do this using look-ahead:

(?i)(?=[a-z]*a)(?=[a-z]*b)(?=[a-z]*c[a-z]*c)([a-z]+)

This regular expression works in Perl; I haven't tested it in BBEdit.

Ronald


 
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.
End of messages
« Back to Discussions « Newer topic     Older topic »