From: Robert Klemme Date: 2008-05-05T19:56:50+09:00 Subject: Re: How would you design regexps in the integer domain? 2008/5/5 Andreas Launila : > 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. Ah! That bit of information was missing from the original posting. > Specifically this is for specifying deterministic finite automatons, > with an integer alphabet, for an upcoming constraint in Gecode/R[1]. I see. Then of course it's a different story. Unless you translate the array of integers into a string and apply a textual regexp. But you can still do that internally, i.e. shield that away as an implementation detail. I'd probably choose the approach we had taken with texrex because it is easy to implement and has good usability (albeit it's a bit verbose). I would base the decision ultimately on the users of such a package, i.e. if they are familiar with regular expressions then the string based approach might be the better choice (short and concise) while for others the wordy approach might be better. Kind regards robert -- use.inject do |as, often| as.you_can - without end