On Feb 21, 2014, at 6:21 AM, Wernher Eksteen <crypt...@gmail.com> wrote:

> Hi all,
> 
> From the below file names I only need the version number 1.2.4 without 
> explicitly specifying it.
> 
>  check_mk-1.2.4.tar.gz
>  check_mk-agent-1.2.4-1.noarch.rpm
>  check_mk-agent-logwatch-1.2.4-1.noarch.rpm
>  check_mk-agent-oracle-1.2.4-1.noarch.rpm
>  mk-livestatus-1.2.4.tar.gz
>  mkeventd-1.2.4.tar.gz
> 
> What regex can I use to obtain only the string value 1.2.4 from the file 
> names (or whatever future versions based on the 3 numbers separated by 3 
> dots, [0-9].[0-9].[0-9]?

Here’s one that will do any number of digits, provided they are preceded by a 
hyphen and followed by a hyphen or period (like all of your samples):

  /-([\d.]+)[.-]/
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to