2009/12/21 Brian Candler <b.candler / pobox.com>:
> Phlip wrote:
>> rx = match('foo') or match('bar') # like /(foo|bar)/
>
> Aside: you either need to use '||' instead of 'or', or you need extra
> parentheses, i.e.
>
> rx = (match('foo') or match('bar'))
>
> otherwise it parses as
>
> rx = match('foo')) or match('bar')
>
> I don't really have a problem with regexps as they are. Although I'd
> like to have more limited, *true* regexps, which compile to a DFA and
> never backtrack.

Nowadays DFA's are rare because NFA provide more features and you can
use them to your advantage (i.e. prioritizing by ordering
alternatives).  You can "switch off" backtracking by using atomic
groups and greedy quantifiers:
http://www.geocities.jp/kosako3/oniguruma/doc/RE.txt

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/