fun with egrep's backtracking and greedy alternation



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



Relevant Pages