Szia!
Javaslom a non capturing groupot: (?:pattern)
Üdv: Mijo
#!/usr/bin/perl
use strict;
use warnings;
my @tests = (
'#0546NNN124:CH/FT0/FM2 RS ok',
'#0546NNN124:CH/FT2 RS ok',
);
for my $test ( @tests ) {
if ( $test =~ m!^
(\#0546NNN124:CH/FT\d+
(?:/FM\d+)?
)
\s+
RS
\s+
(\S+)
\s*
$!ix
) {
print "Match: code=[".$1."] status=[".$2."]\n";
} else {
print "No match: [". $test ."]\n";
}
}
./test.pl
Match: code=[0546NNN124:CH/FT0/FM2] status=[ok]
Match: code=[0546NNN124:CH/FT2] status=[ok]