From: Robert Klemme Date: 2012-04-02T16:40:57+09:00 Subject: Re: Ruby regex match hex string Ammar Ali wrote in post #1054416: > On Sat, Mar 31, 2012 at 9:58 PM, Niels Steves > wrote: >> >> /\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/ Just a tiny remark: this one should be more efficient /\A\h{1,2}(?:,\h{1,2})*\z/ because it avoids backtracking of the NFA and does not use a capturing group. Kind regards robert -- Posted via http://www.ruby-forum.com/.