Click here to Skip to main content
15,880,392 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Validate using Regular Expression
4500788390 14-AUG-2017

What I have tried:

Plz Describe your effort will be highly appreciated. Thanks
Posted
Updated 6-Oct-17 1:16am
Comments
Thanks7872 6-Oct-17 7:02am    
What do you mean by validate?
Member 12857358 6-Oct-17 7:06am    
I want to validate a textbox like some digits one space after that Date as mentioned in question.In textbox string should be like that.

1 solution

Try:
^\d{1,10}\s+\d\d-(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)-\d{4}$
But ... it's a bad idea.
Use a regex to split it into the number and date portions:
C#
^(?<Number>\d{1,10})\s(?<Date>\d\d-...-\d\d\d\d)$
And then use DateTime.TryParse or DateTime.TryParseExact to check and convert the date. Regexes are not good at verifying date info - there are too many exceptions!
 
Share this answer
 
Comments
Member 12857358 6-Oct-17 8:31am    
Thanks its working.
OriginalGriff 6-Oct-17 8:36am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900