b3ta.com talk
You are not logged in. Login or Signup
Home » Talk » Message 614721 (Thread)


/^#([0-9a-f]{1,2}){3}$/ says repeat any of the characters from 0-9 or a-f at least once but no more than twice. Then it says repeat the last grouped expression 3 times. So since the previous expression can be 1 or 2 this could mean that it would validate at 3,4,5, or 6 characters. I know i said 3 or 6 in my last post but I didn't think it all the way through. it could be between 3 and 6 characters. To validate only 6 characters try this

/^#[0-9a-f]{6}$/i


shameless c&p from this
(, Sun 3 Jul 2005, 17:32, archived)
i can just about see that
but i don't understand the use of ^ or $
(, Sun 3 Jul 2005, 17:35, archived)
I don't know anything about it,
but it looks like /^ and $/ mark the start and end of the rule used

edit: www.amk.ca/python/howto/regex/regex.html#SECTION000510000000000000000
(, Sun 3 Jul 2005, 17:39, archived)