in reply to regexp causes segfault

This will do it, but may be slow when failing:

/'(?:[^\\']*(?:\\.|'' )?)*'/

I think the slow failure mode can be overcome with a cut operator:

/'(?:(?>[^\\']*)(?:\\.|'' )?)*'/

Hugo

Replies are listed 'Best First'.
Re: Re: regexp causes segfault
by hv (Prior) on Mar 06, 2003 at 01:36 UTC

    I should clarify that this won't match exactly the same strings as code in the original post, since it always treats a backslash as escaping the following character, so that "'\\'" would be treated as a valid quoted string of a single escaped backslash, whereas the original code would ignore the first backslash and then treat the second backslash as escaping the quote. (And then fail, and backtrack, and do the right thing anyway: "'\\''" would probably be a better example.)

    Hugo