fun with egrep's backtracking and greedy alternation
- From: rabbits77 <rabbits77@xxxxxxxxxxx>
- Date: Mon, 26 Jan 2009 23:18:33 -0500
Ok, so I am trying to match 3 characters but in *any* order.
I know that egrep has both backtracking and greedy alternation so
I have the following
echo 1b22a33c | egrep '(a)|(b)|(c)|(.*\1.*\2.*\3.*)|(.*\3.*\1.*\2.*)|(.*\1.*\3.*\2.*)|(.*\3.*\2.*\1.*)|(.*\2.*\1.*\3.*)|(.*\2.*\3.*\1.*)'
This will work except that I am not sure that the match is from any of the final 6 alternates.
If this were perl I could check to see if $4, $5, $6, $7, $8, or $9 where not undef and know I had a good match of the three characters in any order!
Is there any way to get egrep to do this or something similar? That is, return just the part of the string that matches rather than the whole
line?
.
- Follow-Ups:
- Re: fun with egrep's backtracking and greedy alternation
- From: Dave B
- Re: fun with egrep's backtracking and greedy alternation
- From: John W. Krahn
- Re: fun with egrep's backtracking and greedy alternation
- From: Ed Morton
- Re: fun with egrep's backtracking and greedy alternation
- Prev by Date: Re: Start and end time of a job
- Next by Date: Re: fun with egrep's backtracking and greedy alternation
- Previous by thread: Start and end time of a job
- Next by thread: Re: fun with egrep's backtracking and greedy alternation
- Index(es):
Relevant Pages
|