From: Martin DeMello Date: 2009-10-06T17:15:47+09:00 Subject: Re: Opinions wanted! Is Ruby a good choice for... On Tue, Oct 6, 2009 at 1:21 PM, Kioko -- wrote: > If you want to match strings against each other and want to use > wildcards you need to use regexp. "Basic use" of ? and * are not > supported and you need to create a workaround. (my prior question to > this: http://www.ruby-forum.com/topic/194761#849565 ) > The bad side is that IRC sets bans in this form and not in regexp, also > a normal user would set its userhost as mynick!*myident@*.some.thing and > wouldn't use regexp, either. It's not too hard to handle this sort of thing - just convert the pattern to a regexp and store the regexp internally. Conversion is simply a matter of Regexp.compile(pattern.gsub('.', '\.').gsub('*', '.*')) that is, replace "." with "\." to match a literal . character, then replace * with .* since that's the regexp equivalent. > Is it possible to code such a bot(net) by using Ruby? (sure, but I don't > like workarounds) > .. or maybe a better question: > Would you advise it? Absolutely. Ruby's one of the most maintainable languages I've used, and I've used a lot. Plus it's a lot of fun to code in. martin