From: Robert Klemme Date: 2007-04-18T01:10:07+09:00 Subject: Re: Slow ruby regexes On 17.04.2007 17:44, MenTaLguY wrote: > On Tue, 17 Apr 2007 23:10:11 +0900, Robert Klemme wrote: >> LOL - now I'm confused, too. :-) I was looking for something like (made >> up fake): "To prioritize branches of an alternative in sed you do sed -e >> 's/foo(!2bar|!1baz)/yummy\1/g'." Of course this does not work with sed >> (at least no implementation of sed that I know). Are there other tools >> that allow to embed something into a RX that will do this prioritization? > > OHHHHHHHH. I hope it doesn't hurt too much. ;-) > | is a deterministic choice operator, so the branches are prioritized by default -- earlier alternatives take precedence over later ones. Just write your RX alternatives from highest to lowest priority. > > Does that answer your question? Maybe. :-) I was under the impression that this precisely is a point of difference between NFA and DFA based engines: sed is DFA based and for all I know order in an alternative does not matter while it does matter for the typical NFA engine. Did I get this wrong? Kind regards robert