Your problem is perfectly suited to a solution involving the application of quantum regular expresion dynamics (QRED). Your code as it stands attempts to match each type of emoticon in turn; thus, it is jumping the gun and testing the match before the match actually occurs, but the test changes the match and forces it to happen in a certain way -- which isn't what you want. Instead, you want to write your regex so that it will match either type of emoticon; thus, as it matches, it enters a superposition of states wherein it is simultaneously both a smiley and a winkie. *Then* you test which it is, and at that point the waveform collapses to a particle and you get your answer, which you can use to decide which replacement text to use.
In other words, do what Ed Halley said.
{my$c;$ x=sub{++$c}}map{$ \.=$_->()}map{my$a=$_->[1]; sub{$a++ }}sort{_($a->[0 ])<=>_( $b->[0])}map{my@x=(& $x( ),$ _) ;\ @x} split //, "rPcr t lhuJnhea eretk.as o";print;sub _{ord(shift)*($=-++$^H)%(42-ord("\r"))};
In reply to Re: Why doesn't non-greediness work?
by jonadab
in thread Why doesn't non-greediness work?
by kiat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |