in reply to Detect STX and ETX hex in received string
use Modern::Perl; my $STX = 'a'; my $ETX = 'z'; my $re = qr{ [$STX] (?: (?<match>[^$ETX]{80}) | (?:(?<match>[^$ETX]{0, +79}) [$ETX])) }x; $_='a12345678za1234567890123456789012345678901234567'. '890123456789012345678901234567890123456789012345678901234567890z'; say $+{match} while (/$re/g);
Note that this uses named capture to put either set of matching parentheses into a single variable.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Detect STX and ETX hex in received string
by MidLifeXis (Monsignor) on Nov 28, 2012 at 13:32 UTC | |
by ColonelPanic (Friar) on Nov 28, 2012 at 13:48 UTC |