hi...i want to use the preg match function to verify a string that should have the format format of a year - two digits - two letters - two digits, like this: [in]2005-03-IT-031[/in] thanks
realnsleo
0
Light Poster
Recommended Answers
Jump to PostOk, so what is the question?
Jump to Post<?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"; } ?>
All 6 Replies
azimuth0
1
Light Poster
johny_d
23
Junior Poster in Training
azimuth0
1
Light Poster
johny_d
23
Junior Poster in Training
realnsleo
0
Light Poster
johny_d
23
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.