A Regular Expression Problem in Perl 5.28

"Martin McCormick" <[email protected]> Tue, 28 Mar 2023 15:17:07 -0500
Newsgroups gmane.comp.lang.perl.beginners
Message-ID <[email protected]>
I've been fighting this for several days and it is a very simple
regular expression problem that should be easy enough for a
second grader but I can't seem to get it to work.

	The string I am interested in testing for starts with 5
or 6 digits in a row and all I need to do is determine that the
first 5 or 6 characters are numbers Period.  That's all.

	For some reason, it has never passed the test.

#!/usr/bin/perl -w
use strict;

use warnings::unused;
use File::Copy;

#main local variables
my $workname  = '106787pdtb';
my $regextest = '/^\d+\{5,\}/';
if ( $workname =~ $regextest ) { print "yes\n"; }

$workname contains the data I am testing.  $regextest is the test
for the first 6 characters.

	I was able to do this the hard way and test with 6 \d's
as in

my $regextest = '\d\d\d\d\d\d';
if ($workname =~ $regextest) {print "yes\n"; }

I got a yes that time but that's not good enough.

I'll probably kick myself when I find out what I am missing, but
I can't seem to get this to work.

	Thank you.

Martin McCormick

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/