On Wed May 25 16:25:07 2016, bob.kleemann@everyonecounts.com wrote:
Show quoted text> It seems that the version regex does not do longest match first.
>
> $ perl -Mversion=0.77 -E 'say $version::VERSION; $v =
> "snapshot-1.2.3ga-001-432"; say version->parse( $v =~
> /($version::LAX)/ ); say
> version->parse( $v =~ /($version::STRICT)/ )'
> 0.9912
> 1.
> 1.2
>
> I would expect it to print out "1.2.3", or something similar.
Those regexes were never really intended to be used to capture a version out of a random string. They were primarily intended to be used for is_strict() and is_lax().
However, I have discovered that because of Perl's greedy matching algorithm, several of the alternations need to be swapped so that the longest match is found first (which is why you got the trailing decimal). This works now:
$ perl -I blib/lib/ -I blib/arch/ -Mversion -wE 'say $version::VERSION; $v =
"snapshot-1.2.3ga-001-432"; say $v =~ /($version::LAX)/;'
0.9916
1.2.3
I will point out that your example will never work with $version::STRICT because that requires a leading 'v' for dotted-decimal versions.
John