Android Question RegEx for time formatting?

techknight

Well-Known Member
Licensed User
Longtime User
I have a text box that requires an input of HH:MM:SS or even just MM:SS so if someone wants to set something for 13 seconds, it needs to be formatted as 00:13

Is there a regular expression that checks its formatting to make sure it ONLY contains the correct characters? so someone cant put "garbage" or too many numbers in there?

RegEx is definitely my weakest point in programming.

any ideas? thanks.
 

udg

Expert
Licensed User
Longtime User
I ported a very nice component originally written for B4J by Erel: xRegexField
It checks the input from the user by a regex pattern and shows with a colored border invalid data; it should even "lock" the user to that specific field if invalid data is detected.
B4X:
^([0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$
could be a pattern for HH:MM time
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
Just tried the TimeDialog and it does hours and minutes only. Need something for Minutes/Seconds.
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
I ported a very nice component originally written for B4J by Erel: xRegexField
It checks the input from the user by a regex pattern and shows with a colored border invalid data; it should even "lock" the user to that specific field if invalid data is detected.
B4X:
^([0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$
could be a pattern for HH:MM time

I will try this method. Does this library have the floating hint like the edittext customview does?
 
Upvote 0

udg

Expert
Licensed User
Longtime User
To be honest I can't recall it, but I doubt it. It was just a porting and a way for me to practice with B4X/XUI techniques.
Try it and if it fits your needs (and you're not in a hurry) maybe I could add some features like the floating hint (where can I have a glimpse?).
 
Upvote 0
D

Deleted member 103

Guest
I have a text box that requires an input of HH:MM:SS or even just MM:SS so if someone wants to set something for 13 seconds, it needs to be formatted as 00:13

Is there a regular expression that checks its formatting to make sure it ONLY contains the correct characters? so someone cant put "garbage" or too many numbers in there?

RegEx is definitely my weakest point in programming.

any ideas? thanks.
Have you already tried my library fgTimeKeyboard ?
 
Upvote 0
Top