$re = '/(?:(?<mcversion>\d+\.\d+(?:\.\d+){0,1})-){0,1}(?<fullver>(?<version>\d+(?:\.\d+)*)(?:[-+](?<extra>.*))?)/';
$str = 'Raw Version:
1.0.0
1.2.3.4
1.0
Prefixed with version:
1.7.10-1.2.3
1.8.1-10.0.0.1
1.10.10-2
1.5-4.63.2
Extra Information
1.6-4.4.4.4-SNAPSHOT-BULLSHIT
1.6-SNAPSHOT-BULLSHIT
With Metadata Support
1.0.0-alpha+001
1.0.0+20130313144700
1.0.0-beta+exp.sha.5114f85';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php