tags:

views:

98

answers:

3

I keep getting an error for this regular expression:

^((([1-9])|(1[0-2])):([0-5])(0|5)/s(A|P)M)$

It's supposed to be for a time that ends in 0 or 5. So here are some that should work:

  • 1:25 PM
  • 11:00 AM
  • 9:55 PM

But I keep getting this error message:

Internal error matching pattern '^((([1-9])|(1[0-2])):([0-5])(0|5)/s(A|P)M)$' against value '1:00 PM'

What am I doing wrong?

+5  A: 

I think you should use \s not /s

gonzo
it's always the little things...
Ethan
+5  A: 

I think instead of '/s', you're wanting '\s', aren't you?

retracile
+6  A: 

\s, not /s. But you should also make it \s+ since people insert many spaces by accident. Probably wouldn't be a bad idea to begin and end the regex with \s* too. And what if someone puts in a time 09:50? include 0 in that first group.

Vince