A
andreas1234567
Hi,
I want to create a regexp in order to match N word characters followed
by M trailing space(s), where N+M=<a fixed number>, N>1, M>=0.
Not-quite-what-I-want-to-accomplish sample:
use strict;
use warnings;
my @data = (
"39 ", # ok
"0000 ", # ok
"0139 ", # ok
"000139", # ok
" 0139", # nok
);
for (@data) {
# wanted behavior is to match on 6 word characters, or any word
# characters with trailing space(s), 6 characters long in total.
print "'$_': "; (m/^(\w+\s*){6}$/) ? print "ok\n" : print "nok\n";
}
__END__
'39 ': nok
'0000 ': nok
'0139 ': nok
'000139': ok
' 0139': nok
Any regexp masters online?
I want to create a regexp in order to match N word characters followed
by M trailing space(s), where N+M=<a fixed number>, N>1, M>=0.
Not-quite-what-I-want-to-accomplish sample:
use strict;
use warnings;
my @data = (
"39 ", # ok
"0000 ", # ok
"0139 ", # ok
"000139", # ok
" 0139", # nok
);
for (@data) {
# wanted behavior is to match on 6 word characters, or any word
# characters with trailing space(s), 6 characters long in total.
print "'$_': "; (m/^(\w+\s*){6}$/) ? print "ok\n" : print "nok\n";
}
__END__
'39 ': nok
'0000 ': nok
'0139 ': nok
'000139': ok
' 0139': nok
Any regexp masters online?