| | |
help with preg match
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
PHP Syntax (Toggle Plain Text)
<?php $string = '2005-03-IT-31'; if (preg_match ('/^[\d]{4}-[\d]{2}-[a-z]{2}-[\d]{2}$/i',$string)) { echo "Right format"; } else { echo "Wrong format"; } ?>
•
•
Join Date: May 2006
Posts: 36
Reputation:
Solved Threads: 5
That won't work, unless I'm reading it wrong...
PHP Syntax (Toggle Plain Text)
<?php $string = '2005-03-IT-31'; if (preg_match('/^\\d{4}-\\d{2}-[a-z]{2}-\\d{2}$/i',$string)) { echo "Right format"; } else { echo "Wrong format"; } ?>
Last edited by azimuth0; May 22nd, 2007 at 6:19 pm. Reason: odd tag showed up?
The way I wrote it , it works.
The way you wrote it , it doesn't.
PHP Syntax (Toggle Plain Text)
... [\d]{4}...
The way you wrote it
PHP Syntax (Toggle Plain Text)
... \\d{4} ...
Last edited by johny_d; May 22nd, 2007 at 7:25 pm.
![]() |
Similar Threads
Other Threads in the PHP Forum
- Previous Thread: HELP! I get an erro when including PEAR.php file
- Next Thread: Template
Views: 3820 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email encode error file files folder form forms function functions google howtowriteathesis href htaccess html image include insert integration ip java javascript joomla jquery limit link login loop mail menu methods mlm mod_rewrite multiple multipletables mysql oop parse paypal pdf php problem provider query radio random recursion regex remote script search select server sessions sms soap source space speed sql structure syntax system table template tutorial update updates upload url validation validator variable video web xml youtube





