I have a problem with preg_match

$versionstring[1] = 'Version: ImageMagick 6.4.6 2010-01-20 Q8 OpenMP http://www.imagemagick.org Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC';

preg_match('#^Version: [^0-9]*([ 0-9\\.\\:Q/\\-]+) (http|file)\:#i', $versionstring[1], $matches)) 

returns false

how can i fix this ?

有帮助吗?

解决方案

OpenMP was added to the ImageMagic version string since your regex was working, so as a quick fix, you can just add OpenMP like this:

preg_match('#^Version: [^0-9]*([ 0-9\\.\\:Q/\\-]+) OpenMP (http|file)\:#i', $versionstring[1], $matches);

But just be aware that this could happen again on future upgrades, so depending on what you're using this for, you think about making the regex less string specific and just pull out the information you need.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top