On 07.08.2007 05:10, Ari Brown wrote:
> I'm moderately serious. This is going to be one of those projects that 
> won't see the light of day for maybe 6 months to a year.
> This looks largely what I was hoping to make, although in Ruby I had 
> invisioned this:
> 
> matching email addresses (sample):
> a = LeetExp.new(:letters => [[a-z], :insensitive],
>                 :string => "@",
>                 :letters => [[a-z], :insensitive],
>                 :string => ".",
>                 :string => ["com", "net", "org", "edu"]
> )

You cannot do this because Hashes are unordered so you loose the 
original order.  Also [a-z] is only valid if you define local variables 
a and z.

Personally I find regular expressions pretty readable - at least if they 
are crafted properly. :-)  See also below.

> case line
> when a
>     # ...
> 
> My idea is to make it logical and human readable. Ruby is a language for 
> humans and UberBeings, and I think this should reflect Ruby's ideas.

Do you know the /x modifier?  Than can go a long way to make a regular 
expression readable.  For example:

input = <<TEXT
adjasdkajda dadkajd foo / bar.com adklskkdaldjskj
postmaster / root.edu adkjasdjk
blah@org akjsd askdl asd noname / foo.net hello
asdj
TEXT

input.scan %r{
   \b            # word boundary
   (?i:[a-z]+)   # user name
   @             # the famous "at" sign
   (?i:[a-z]+)   # host name
   \.            # a literal dot
   (?:com|net|org|edu)   # only some of the TLDs
   \b            # word boundary
}x do |match|
   puts "Found email address #{match}"
end

Kind regards

	robert