troubleshooting Question

Regex to validate date/partial date for sql

Avatar of majiga
majiga asked on
PerlPHPRegular Expressions
10 Comments2 Solutions1082 ViewsLast Modified:
hi can someone please give me a regex which will help me validate dates and which works in php4. it needs to allow numbers, hyphens and percentage signs (it will be used in a sql query)

some examples of valid strings:

2007-08-27
2007-08%
2007%
%-08-%
%-15

thankyou!

(trying to understand a bit of regex here; but whatever I try just isn't doing what it seems it should!)
ASKER CERTIFIED SOLUTION
DarkoLord

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros