Well, if you have N335G03X247.7.16Y580.07K and your pattern is N<n>G03X<x>Y Then we know that numbers are actual numbers 0-9 and can contain a dot as decimal separator, thus the regular expression to match this is:
You can then use this to get the rest of the variables, then check if they have the right values... or at least defined, for example if $n and $x has been defined:use strict; use warnings; my $line = "N335G03X247.16Y580.07K6.89J96.62H1M25 N340M20 N345G45"; my($n, $x); if($line =~ /N([0-9\.]+)/){ $n = $1 }; if($line =~ /G03X([0-9\.]+)/){ $x = $1 };
if( $line =~ /N([\d\.]+)/ ){ $n = $1 }; if( $line =~ /G03X([\d\.]+)/ ){ $x = $1 };
In reply to Re: Using regular expressions to find patterns in machine tool data
by FreeBeerReekingMonk
in thread Using regular expressions to find patterns in machine tool data
by merrymonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |