Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

matching the string

Status
Not open for further replies.

veteq

Technical User
Dec 7, 2004
23
0
0
CA
I need some help with this "string match"

( $ans_quantity !~ /^[0-9]{3}d/)

what I am trying to do is for the user to enter a min of 1 numeric digit and not more that 3 numeric digits (not allowing alpha numeric characters)

thank you...

Veteq
 
There is possibly a more elegant way to put it, but this works:

($ans_quantity !~ /^[0-9]$|^[0-9]{2}$|^[0-9]{3}$/)


FNL
 
how about

$ans_quantity =~ /^\d{1,3}$/

this matches 1 to 3 digit
 
that worked great, thank you for your quick reponses

Veteq
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top