• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Inverse Regex Library?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Inverse Regex Library? (From: Philip Mötteli <email@hidden>)

  • Prev by Date: master-detail: binding array controller to the attribute of selection of master array controller
  • Next by Date: Re: Problem on clearing points and paths on a NSView
  • Previous by thread: Re: Inverse Regex Library?
  • Next by thread: Re: Inverse Regex Library?
  • Index(es):
    • Date
    • Thread