I assume, you want single matched lines and not blocks of matched lines. Then you could use something like this:
which yieldsuse strict; use warnings; while (defined(my $line = <DATA>)) { if ($line =~ m{ \A N \d+ G \d+ X \d+ \.? \d* Y \d+ \.? \d* K \d+ \.? \d* J \d+ + \.? \d* H 1 M 25 \n \z | \A N \d+ M 20 \n \z | \A N \d+ G 45 \n \z | \A N \d+ G 01X \d+ \.? \d* Y \d+ \.? \d* C \d+ \.? \d* M 25 \ +n \z }xms) { print $line; } } __DATA__ N335G03X247.16Y580.07K6.89J96.62H1M25 N340M20 N345G45 N350G01X832.56Y692.92C275.44M25 N355M20 N360G46C0 N365G03Y720.88I146.74J13.98H36M25
Update: added end-of-line anchors in regular expressions.N335G03X247.16Y580.07K6.89J96.62H1M25 N340M20 N345G45 N350G01X832.56Y692.92C275.44M25 N355M20
In reply to Re: Using regular expressions to find patterns in machine tool data
by hexcoder
in thread Using regular expressions to find patterns in machine tool data
by merrymonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |