I would like to extract the version number from the url content. i tried to extract info using curl_exec. but unable to get the preg_match to get the exact info.
Code i tried is
function getVersionFromurl(string $url)
{
$curl = curl_init($url);
$content = curl_exec($curl);
curl_close($curl);
$rx = preg_match("(\"version\" (\d+\.\d+\.\d+\.\d+))", $content, $matches);
echo $matches[1];
}
$url = 'https://www.foxitsoftware.com/downloads/downloadForm.php?retJson=1&product=Foxit-Reader&platform=Mac-OS-X';
$val = getVersionFromurl($url);
here the content came as
"{"package_info":{"language":["English","French","German","Italian","Spanish"],"type":["pkg"],"version":["3.4.0.1012","2.1.0804","2.0.0625","1.1.1.0301","1.1.0.0128"],"size":"139.13MB","release":"10/15/19","os":"","down":"/pub/foxit/reader/desktop/mac/3.x/3.4/ML/FoxitReader340.setup.pkg","mirror":"","manual":"","big_version":"3.x"}}1"
How to extract 3.4.0.1012 from the content. the preg_matcxh i tried gives me error. how to write the preg_match regular expression.
Please any help.
"version":\["(\d+(?:\.\d+){3})"See regex101.com/r/wen7ya/1