
wayne at schlitt
Sep 1, 2006, 12:18 PM
Post #15 of 24
(5124 views)
Permalink
|
In <Pine.LNX.4.44.0609011357080.32489-100000 [at] bmsred> "Stuart D. Gathman" <stuart [at] bmsi> writes: > On Fri, 1 Sep 2006, Stuart D. Gathman wrote: > >> On Fri, 1 Sep 2006, wayne wrote: >> >> > I could translate the above abnf to a regex, if anyone *really* >> > cares... > > The abnf Ruby module doesn't seem to be available anymore. All the > links I can find give 404 for the download. :-< I sent email to the author and asked what's up. I still have a copy of the tarball, so maybe I'll host it if he no longer wants to. >> I care, and came up with the following regex manually for pyspf: >> >> PAT_IP4 = r'\.'.join([r'(?:\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])']*4)+'$' >> HEXSEQ = r'(?:[0-9a-f]{1,4}(?::[0-9a-f]{1,4})*)' >> RE_IP6 = re.compile( >> r'%s?(?:::)?%s?(?::%s)?'%(HEXSEQ,HEXSEQ,PAT_IP4),re.IGNORECASE) >> >> Seems rather complex. Is yours simpler? lol you must not remember the regular expressions I posted a while back (a year ago?) that would match SPF records. No, the converted stuff is *not* simplier. Mind you, once it is compiled, I doubt there is any significant speed differences. Here it is, slightly munged: (wayne [at] footbon) $ ruby range_abnf.rb 2>/dev/null | convert_re ^::| ([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}| ([0-9A-Fa-f]{1,4}:){1,8}:| ([0-9A-Fa-f]{1,4}:){7}:[0-9A-Fa-f]{1,4}| ([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}){1,2}| ([0-9A-Fa-f]{1,4}:){5}(:[0-9A-Fa-f]{1,4}){1,3}| ([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){1,4}| ([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){1,5}| ([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){1,6}| [0-9A-Fa-f]{1,4}:(:[0-9A-Fa-f]{1,4}){1,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[0-5])\. ([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\. ([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])| ([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4} ([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\. ([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\. ([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\. ([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])| [0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5} ([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\. ([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\. ([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\. ([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])| ::([0-9A-Fa-f]{1,4}:){0,6}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\. ([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\. ([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\. ([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$ -wayne ------- To unsubscribe, change your address, or temporarily deactivate your subscription, please go to http://v2.listbox.com/member/?listname=spf-devel [at] v2
|