in reply to Re: Pattern matching: Lazy vs. greedy
in thread Pattern matching: Lazy vs. greedy

Dear QM, Thank you for your suggestion. In the specific case I am working on here, I can’t categorically rule out repetitions of the first word, but I’ll keep your solution in mind.
  • Comment on Re^2: Pattern matching: Lazy vs. greedy

Replies are listed 'Best First'.
Re^3: Pattern matching: Lazy vs. greedy
by QM (Parson) on Mar 31, 2015 at 08:46 UTC
    ... I can’t categorically rule out repetitions of the first word, ...

    Can you elaborate on the rules or goals you have in mind?

    I would guess something like "shortest matching string" or "string with the smallest number of words" (for some value of $words). It's not necessarily easy to come up with this, but you should be able to list positive and negative examples to help tune the solution.

    And most of us are just nerdy enough to want more specifics so we can solve it, or near enough. (Allowing the dreams of examples and counter-examples to be replaced once again by the more familiar nightmares of github DDOSs or Linus rants.)

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of