From: Andreas Launila Date: 2008-05-05T18:51:51+09:00 Subject: Re: How would you design regexps in the integer domain? Robert Klemme wrote: > 2008/5/5 Andreas Launila : >> I'm trying to come up with a clean way to specify regexps in the integer >> domain. I.e. instead of describing a pattern of characters (as in normal >> regexps) one describes patterns of integers ("17 followed by 3 or 15" >> rather than "'a' followed by 'b' or 'c'"). > > Why do you need this, i.e. what advantages do you expect for a > particular "integer regexp" over classic regular expressions? > The two types of regexps are not really comparable since they work in different domains. I.e. classic regular expressions describe patterns in arrays of characters rather than in arrays of integers. One could for instance use an integer regexp to decide whether an array begins with 17 and ends with 8. Specifically this is for specifying deterministic finite automatons, with an integer alphabet, for an upcoming constraint in Gecode/R[1]. >> >> IntRegexp.new('(17|1 5)*4711') > > You can as well do /(17|1 5)*4711/, can't you? > True, assuming that one then convert it back to its source to reparse. It would probably make it even more familiar. [1] http://gecoder.rubyforge.org/ -- Andreas Launila