autopkg/autopkg — pull request #66 by jessepeterson (2014-01-20 21:23:00+00:00)
Title: URLTextSearcher: Use last regexp match group rather than first

Per comments in #64, reproduced here:

> In addition to #65 I found another problem. For regexp normal groups (non-named) that have a sub-pattern it currently only returns the first group (0). This means that, for example, the regexp `Version ([0-9a-z\.]*)` will, without a named group, will return `Version 1.0a` instead of what is wanted: the second group (1) (just the `1.0a`).
>
> To solve this I see a few choices:
> 1. Have an input variable to select the match you want.
> 2. Return all matches with a suffix to the output variable. E.g. `match`, `match1`, `match2`, or in the case of a `result_output_var_name` (say, `url`) it would be `url`, `url1`, etc. This could get messy with many output vars for a regexp with many groups named or otherwise (since we can't really tell named vs. non-named).
> 3. Simply return the *last* group of the regexp (instead of the *first* as it operates now). This has the benefit that if there are no sub-patterns it works as it does now.
>
> Or a combination of those or something I haven't thought of. My vote would go to number 3. Thoughts? I can squeeze this into the PR on #65 if pick a solution is picked.