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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with checking strings

Status
Not open for further replies.

Markh51

Programmer
May 20, 2003
81
GB
Hi,

I have a smal script which checks for the amount of figures either side of a decimal point:

decReg = "^[0-9]{"+lmin+","+lmax+"}\\.[0-9]{"+rmin+","+rmax+"}$"

lmin & lmax; define the amount of number that have to be on the left side of the point

rmin & rmax; same as above, but for the right side.

What I need to know, the above script makes the user enter the "." even if they put in a round figure, how can I change the above to mean: "only check the right hand side if the decimal point exists" ???

Thanks,
Mark
 
I don't think you'll be able to without split()ing the value at the "." position and then just validating that porition with the regex. unless you just want to set the pattern to accept any numeric amount in the whole numebr
"^[0-9]*\.[0-9]{"+rmin+","+rmax+"}$

____________________________________________________
Python????? The other programming language you never thought of!
thread333-584700

onpnt2.gif
 
what i really want is, if a user enters a decimal point then the script should only allow 2 figures after that.

How would I go about that ???
 
no, it's OK, the pattern you give me works fine for me.

Cheers,
mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top