UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Testing Whether A String Matches A Given Format.    
 
   
Kamulegeya
post Feb 22 2014, 05:23 AM
Post#1



Posts: 1,767
Joined: 5-September 10
From: Kampala,Uganda The Pearl of Africa


Hello community.
How can i test in code whether values entered in Text field match the format "yyyy-mm-dd"?
Ronald
Go to the top of the page
 
Kamulegeya
post Feb 22 2014, 09:01 AM
Post#2



Posts: 1,767
Joined: 5-September 10
From: Kampala,Uganda The Pearl of Africa


Found this
CODE
String pattern="^(19|20)\\d\\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])$";
String tomatch=readingDate.getText().toString();
                        isvalid=tomatch.matches(pattern);

and works great....regex looks like Arabic to me!
Go to the top of the page
 
orange999
post Feb 22 2014, 09:24 AM
Post#3



Posts: 1,714
Joined: 10-February 08
From: Ottawa, Ont, Canada; West Palm Beach, FL


regex is great for pattern testing, matching and/or extraction.
I'm not a java C# programmer, but have used it with Access and VBA.
There are many articles/tutorials/examples on the internet.
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    16th December 2017 - 06:09 AM