From: Robert Klemme Date: 2005-03-21T18:44:50+09:00 Subject: Re: Iterating through a string and removing leading characters "Randy Kramer" schrieb im Newsbeitrag news:200503201839.47741.rhkramer@gmail.com... > On Sunday 20 March 2005 03:19 am, Robert Klemme wrote: > > "Randy Kramer" schrieb im Newsbeitrag > > > I planned to do that, I'll try to > > > put something on WikiLearn this weekend then post something here. > > See http://twiki.org/cgi-bin/view/Wikilearn/RWP_RE_Tests -- it's rather ugly > but the information is there. > > Randy Kramer Some remarks: - The comparison between 5 and 6 does not seem fair, as you iterate in 6 but not in 5. - You don't use String#scan or #split which you are likely to need in practice, because you want to sift through complete documents and want to treat all occurrences. - The differences between the check-first-char approach and the pure RE approach are so insignificant that I'd not bother using the more complex code. I'd stick with pure RE based approaches and only try to optimize if performance is bad. (You mentioned premature optimization already... :-)) Kind regards robert