Re: Inverse Regex Library?
Re: Inverse Regex Library?
- Subject: Re: Inverse Regex Library?
- From: Steve Byan <email@hidden>
- Date: Wed, 23 Jul 2008 12:16:09 -0400
On Jul 17, 2008, at 10:09 AM, Philip Mötteli wrote:
Does anybody know of a library, that takes a bunch of strings and
produces a regex-string from them?
E. g:
"Word1"
"Word2"
"Word5"
"Word8"
"Word11"
"Word19"
"Word23"
"Word45"
"Word77"
should give "Word[0-9]{1,2}". Or I would even be more happy with
"Word[0-9]+".
I've heard of Grail+. But are there any other options?
Check out Sequitur: <http://sequitur.info/>.
For your example, Sequitur gives the following grammar:
Rule Expansion
S -> 0 -> 1 2 \2 3 4 \8 3 \1 2 \1 \9 3 \2 \3 3 \4 4 \7 \7 \n \n
1 -> W o r d Word
2 -> \1 3 \1\nWord
3 -> \n 1 \nWord
4 -> \5 3 \5\nWord
Not perfect, but looks like it could be converted to a usable regex.
To use Sequitur on multiple sequences (i.e. each word individually),
run the Sequitur algorithm on each sequence, but share the Sequitur
state between them.
Best regards,
-Steve
--
Steve Byan <email@hidden>
Littleton, MA 01460
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden