From: Ryan Leavengood Date: 2005-04-21T02:27:19+09:00 Subject: Re: Another(!!) Newbie question Thanks for the information and link. I wrote the example for kyu like I did to purposely keep it simple. But he should definitely use something more like your regex in his final code. So kyu, if you are listening, please do so :) Also that link is a good read for anyone who likes to use regular expressions (which is probably every Ruby programmer.) I have a copy of "Mastering Regular Expressions" (mentioned in the link) on a CD somewhere...I need to find it and do some review. Ryan Jacob Fugal wrote: > > As a general rule, remember that .* is "evil"[1]. There are times when > it is useful, but usally it is not what you want. The semantics are > too liberal introducing possible mismatches and even when correct it > is one of the slowest of possible alternatives. Usually the . can be > replaced with a negation of the character set of whatever follows. For > example, I'd write the above regex as: > > /^:([^!]*)!(\S*)\s(\S*)\s#(\S*)\s:(.*)$/ > > Jacob Fugal > > [1] http://perlmonks.org/index.pl?node_id=24640