in reply to Re: Pattern Matching, left-to-right
in thread Pattern Matching, left-to-right

fun with perl:

substr($_, pos() - 3, 3) =~ tr/FSTRE\\/|^&~\\/d while m/\G.*?\\[FSTRE]\\/gs;
Note: s modifier is required in the regexp

Update: regexp was simplified

substr($_, pos() - 3, 3) =~ tr/FSTRE\\/|^&~\\/d while m/\\[FSTRE]\\/g;

Replies are listed 'Best First'.
Re^3: Pattern Matching, left-to-right
by Aristotle (Chancellor) on Aug 22, 2004 at 09:07 UTC

    Yep, although that wasn't really the point of my excercise. :-) I'd write that one a little differently:

    my %xlat = ( F => '|', S => '^', T => '&', R => '~' E => '\\', ); while( m/ \G .*? \\([FSTRE])\\ /gsx ){ substr $_, pos() - 3, 3, $xlat{ $1 }; }

    Update: same change as in parent node update applies.

    Makeshifts last the longest.