Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I extract a major and minor version number from the end of a string?

I’m trying to extract the CMS Tikiwiki version, but I have a problem extracting the version.
I’m able to extract only the first part of the number, example:

Version 15.0, I can extract only 15, but I want to extract 15.0.

if ($res=~ m/as of version (.+?)\./) {

  $version = $1;

 }

Sentences to extract version

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The following list attempts to gather the copyright holders for Tiki as of version 15.0.

>Solution :

Try this,

if ($res =~ m/as of version (\d+(?:\.\d+))\./) {

If this is the end of the string you may want,

if ($res =~ m/as of version (\d+(?:\.\d+))\.$/) {

The pattern (\d+(?:\.\d+)) captures any digit followed by an optional grouping of . and one or more digits.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading