Currently the version pattern, if there is a match, returns the first capturing group.
I would be nice to add a parameter to the function, that defines the expecting capturing group, with a default value of 1 so this does not break any existing code.
This is a very simple improvement but it avoid to define a custom callback for a so little change and avoid duplicate code.
Example of REGEX: /("?)version\1:\s*("?)([0-9\.]+)\2\s*,/
This REGEX use backreferences, that need to define some extra capturing groups.
With the current function, we get a double quote as version number.
With a improved function, we could specify the value 3 as capturing group and get the correct version number.
Comments
Comment #2
b-prod commentedFixes the issue and add documentation in the API file.
Comment #3
chris matthews commentedThe 2 year old patch in #2 to libraries.api.php applied cleanly to the latest libraries 7.x-2.x-dev and if still applicable needs review.