Robert Klemme wrote:
> This has a potential for disastrous backtracking with large strings.
> This one is better - if you can guarantee there there is no "%" besides
> the one preceding the "2F":
> 
> => "2006%2F10%2Fasdfasdf"
>  >> s.match(/^([^%]*)%2F([^%]*)%2F(.*)$/).to_a
> => ["2006%2F10%2Fasdfasdf", "2006", "10", "asdfasdf"]
> 
> Or maybe even
> 
>  >> s.match(/^((?>[^%]*))%2F((?>[^%]*))%2F((?>.*))$/).to_a
> => ["2006%2F10%2Fasdfasdf", "2006", "10", "asdfasdf"]

I have a couple of questions about this; I'm always trying to further my 
(currently basic) understanding of regular expressions.

1. Why does my first regex have a potential for disastrous backtracking? 
(By disastrous I assume you mean inefficient and CPU-time-consuming, 
right?)

2. What does the "?>" do in your second regex? I haven't seen that 
before.

Thanks!

-- 
Posted via http://www.ruby-forum.com/.