Home: Perl Programming Help: Beginner:
\d*



emelin
stranger

Feb 22, 2001, 4:25 AM


Views: 1510
\d*

Doesn't "\d*" mean "any number, at least 0 times"?
I want the user to enter something like P651... my code lets them enter PJJJ (i.e. anything, as long as it has a p or P in it)... How do I just let them enter PXXX, X being a number?

if ($FORM::part =~ /P\d*/i){
continue();
}

thankful for help,
emelin



japhy
Enthusiast

Feb 22, 2001, 7:30 AM


Views: 1508
Re: \d*

The regex \d* means 0 or more digits (0-9). This matches on the string "japhy". Do you see where? Right at the beginning of the string. I can see 0 digits there, and that's what I asked to match.

Perhaps you meant \d+. Or, more specifically, \d{3}.

Jeff "japhy" Pinyan -- accomplished hacker, teacher, lecturer, and author