Re: Yet another regex question

From: Date: Mon, 04 Feb 2002 23:56:12 +0000
Subject: Re: Yet another regex question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-83493@lists.php.net to get a copy of this message
Hello again, > This is excellent. If you don't mind digging out your functions, I'd much > appreciate it... I'll have a look tomorrow. > The previous question was for alpha only, no numeric ...names dont have > numbers, but addresses usually do. Alright, well: [a-z] matches a through z [A-Z] same, upper case [0-9] yup, zero through 9 [ ] space Look up the pattern modifiers, and the pattern syntax in the pcre section of the manual): if (!preg_match("/[a-zA-Z]+$/", $name)) { // $name doesn't consist of characters within a-z or A-Z } > I'd got kinda mixed up there on the date thing...lol. I have a javascript > date picker thingy, but unfotunately it drops leading zeros on the dates and > times. I think, however, your suggestion if pulldowns is much safer, but > the date will be for MySQL or MS Access. I think YYYY-MM-DD HH:MM:SS, as > you suggested would be the answer, and I'll try to add the time into the > $date variable. Just out of curiosity, what are you using this for? I mean, you might be doing more work than you need to be doing..... > The currency is irrelevent here (although will UK£). I just want the 2 > decimal places money format. I have STATE above because thats what the > field is in the database....On display it says state/county. I see - check out number_format(), printf() and sprintf() in the manual - this might already solve some of what you want, though I can't see why you'd need two decimal places in a regex check : $19.95 // one decimal £19.95 // same £19.95.1 // what the? :) Can you elaborate as to why you need 2? Alright, time for sleep. Try and give a bit more info as to what you're using these for (and where, if it's currently being used) your code is failing.. :) Night James

« previous php.general (#83493) next »