473,396 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

RegEx Pattern?

I've never used the patterns before and wondered if anyone could tell me why
this does not work
[00-23]{2}:[00-58]{2}

I just want to validate 24 hour time entry.

Cheers

Luke
Nov 15 '05 #1
4 1332
For the Perl RegEx Syntax, see:

http://groups.google.com/groups?hl=e...TF-8%26hl%3Den

Your expression is treating numeric characters as NUMBERS, not characters.
What you have is essentially:

[0 0-2 3]{2}:[0 0-5 8]{2}, which would more properly be reduced to:
[0-3]{2}:[0-58]{2}

So, the intent of the expression allows 33:88, but not 12:36. (6 isn't
included in the second character class).


"Luke Ward" <lu******@campbelluk.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I've never used the patterns before and wondered if anyone could tell me why this does not work
[00-23]{2}:[00-58]{2}

I just want to validate 24 hour time entry.

Cheers

Luke

Nov 15 '05 #2
((?:(?:[01][\d])|(?:[2][0-3])):[0-5][\d])
should do it.

Ken

"Luke Ward" <lu******@campbelluk.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I've never used the patterns before and wondered if anyone could tell me why this does not work
[00-23]{2}:[00-58]{2}

I just want to validate 24 hour time entry.

Cheers

Luke

Nov 15 '05 #3
I believe this will work; I've tested it somewhat, and I'm sure you can
Google an equally good answer (or try PerlMonks or CPAN.org, that kind of
place).

\b(([0-1]?\d)|(2[0-3])):[0-5]\d\b
Nov 15 '05 #4
I believe this will work; I've tested it somewhat, and I'm sure you can
Google an equally good answer (or try PerlMonks or CPAN.org, that kind of
place).

\b(([0-1]?\d)|(2[0-3])):[0-5]\d\b
Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a...
1
by: Craig Kenisston | last post by:
Hi, I need to write a function that should behave like the SQL's "like" operator on a list of words. I was wondering if I can use Regex directly to do this job. But I've been reading about...
20
by: jeevankodali | last post by:
Hi I have an .Net application which processes thousands of Xml nodes each day and for each node I am using around 30-40 Regex matches to see if they satisfy some conditions are not. These Regex...
9
by: Whitless | last post by:
Okay I am ready to pull what little hair I have left out. I pass the function below my String to search, my find string (a regular expression) and my replace string (another regular expression)....
8
by: vbmark | last post by:
I'm new to RegEx in vb.net so I'm not sure how to do this. I want to know if a string contains two minus signs "-". If there are two then I want it to return TRUE. I also need to know if the...
4
by: shonend | last post by:
I am trying to extract the pattern like this : "SUB: some text LOT: one-word" Described, "SUB" and "LOT" are key words; I want those words, everything in between and one word following the...
8
by: tomb | last post by:
I have found much documentation on specific patterns, but I can't find anything explaining how to reject strings that match both groups. My string could contain specific letters or numbers. If...
8
by: sherifffruitfly | last post by:
Hi, I've been searching as best I can for this - coming up with little. I have a file that is full of lines fitting this pattern: (?<year>\d{4}),(?<amount>\d{6,7}) I'm likely to get a...
1
by: Prabhu Gurumurthy | last post by:
Hello all - I have a file which has IP address and subnet number and I use regex to extract the IP separately from subnet. pattern used for IP: \d{1,3}(\.\d{1,3}){3} pattern used for...
0
by: vmysore | last post by:
I am trying to get all the columns selected within a SQL query (including the sub selects). When the code hits matcher.find(). i get the following exception: Exception in thread "main"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.