// Copyright (c) CNES 2008 // // This software is part of CelestLab, a CNES toolbox for Scilab // // This software is governed by the CeCILL license under French law and // abiding by the rules of distribution of free software. You can use, // modify and/ or redistribute the software under the terms of the CeCILL // license as circulated by CEA, CNRS and INRIA at the following URL // 'http://www.cecill.info'. // Extract version from a string : n.m.k or n.m // If the digit sequence appears several times => returns the rightmost one // str: string containing a version number // numversion: version found as 3 integer numbers, size = 1x3 // strversion: version found as string (3 digits) // exact == 0 => find version anywhere in string // exact == 1 => str must be exactly the version string function [numversion, strversion] = CLx__extractVersion(str, exact) numversion = []; strversion = ""; // detects all sequences, keep the rightmost one [i1, i2] = regexp(str, "/[0-9]+\.[0-9]+(\.[0-9]+)*/"); if (i1 <> [] & i2 <> []) i1 = i1($); i2 = i2($); if (exact == 0 | (i1 == 1 & i2 == length(str))) strversion = part(str, i1:i2); numversion = matrix(strtod(tokens(strversion + ".0",".")), 1, -1); numversion = numversion(1:3); end end endfunction