From: Ammar Ali Date: 2012-04-01T05:09:06+09:00 Subject: Re: Ruby regex match hex string On Sat, Mar 31, 2012 at 9:58 PM, Niels Steves wrote: > Hey guys, > > I was wondering if someone could help me out. > I'm trying to validate a string with a regex but can't get it working. > I need to validate a string containing hex pairs divided by a comma, > like this > > 11,1,aa,a,1b,3b,55,b6 > > I got this regex: > > /\A([0-9a-fA-F]{1,2},{1})*([0-9a-fA-F]{1,2}){1}\Z/ You can use \h to match a hexadecimal digit as well, which match both lower and upper case a-f. /\A(\h{1,2},)*\h{1,2}\z/ Regards, Ammar