From: Ezra Zygmuntowicz Date: 2008-09-23T07:12:51+09:00 Subject: Re: short regexp question On Sep 22, 2008, at 8:10 AM, Robert Klemme wrote: > 2008/9/22 Tod Beardsley : >> Anyway, I think the moral of this particular long-missing story is, >> if >> you can regex test for smaller anchors first, you can then fail to >> match much faster. IOW: >> >> matched =false >> if str.match(/b/) >> matched = true if str.match(/a[^b]*b/) >> end >> matched > > I am not sure. This approach is likely slower than a single fast RX - > at least if you expect matches most of the time. It all depends... Also keep in mind that =~ is generally a lot faster then .match since match has to build the full MatchData object even if you do not use it. Cheers- -Ezra