in reply to How to replace greedy alternation?

It's been ages since I last posted here, but here goes.

Your first statement is false. This egrep doesn't make sure that all characters occur, so it makes sense that it seems to be harder in perl. Egrep tries to match either of the characters you specified, and spits out only the parts that match, because of the -o:
echo 1b22a3d3 | egrep -o 'a|b|c|d' b a d

All Camels are equal, but some Camels are more equal than others.

Replies are listed 'Best First'.
Re^2: How to replace greedy alternation?
by adamcrussell (Hermit) on Jan 28, 2009 at 16:05 UTC
    egrep finds all the cases because it has greedy alternation(the subject of this Seekers...). -o simply has egrep print out the matches it does find. A complete non-perl solution could be something like
    echo 1b22cc333a | egrep -o 'a|b|c' | sort -u | wc -l
    This will simply return 3. If I want 3 chars in any order and this command returns 3 than I had a successful match of all 3 in any order!