On Thu, Jan 01, 2009, Jeff Johnson wrote: > On Jan 1, 2009, at 1:04 PM, Ralf S. Engelschall wrote: >>> >>> A little help vetting the RE's please ;-) My eyes are already tired >>> from writing the toy script, RE's are more effective than XML at eye >>> gouging. >> >> I propose the following three entries in "macros"... >> >> # STEP 1: Match the string and capture regex parts >> # 1 2 3 4 >> # X ":" X "-"X ":"X >> %evr_tuple_match ^(?:([^:-]+):)?([^:-]+)(?:-([^:-]+))?(?::([^:-] >> +))?$ > > A little more help please. > > I'm using POSIX extended RE's.
Oh, sorry. I silemtly assumed PCRE! But ok, a non-PCRE version is also possible: we just have to replace the non-capturing parenthesis (?:..) with regular ones and then just ignore them in the selection phase: # STEP 1: Match the string and capture regex parts # 2 3 5 7 # X ":" X "-"X ":"X %evr_tuple_match ^(([^:-]+):)?([^:-]+)(-([^:-]+))?(:([^:-]+))?$ # STEP 2: Assemble <E,V,R,D> tuple from regex parts # <E,V,R,D> case 1: case 2: case 3: case 4: case 5: case 6: # X:X-X:X X:X-X X:X X: X-X X %evr_tuple_select 2357 237_ 23__ 2___ _23_ __5_ # STEP 3: Configure the comparison order of the <E,V,R,D> tuple elements %evr_tuple_order EVRD This should do the trick with regular POSIX regular expressions, too. Ralf S. Engelschall r...@engelschall.com www.engelschall.com ______________________________________________________________________ RPM Package Manager http://rpm5.org Developer Communication List rpm-devel@rpm5.org