par
stealth35 » 19 mai 2010, 17:05
cheez moi ca marche
$str1 = '>B_1 7.500 750 pos. 136 - 145 1D8E:B';
$str2 = '>BAB78:C_4 3.200 320 pos. 346 - 355 1';
preg_match('/^(?:.(?<!\s))+\s((?:.(?<!\s))+)\s/', $str1, $matches1);
preg_match('/^(?:.(?<!\s))+\s((?:.(?<!\s))+)\s/', $str2, $matches2);
var_dump($matches1, $matches2);
Code : Tout sélectionner
array(2) {
[0]=>
string(11) ">B_1 7.500 "
[1]=>
string(5) "7.500"
}
array(2) {
[0]=>
string(17) ">BAB78:C_4 3.200 "
[1]=>
string(5) "3.200"
}
sinon tu fais un
explode, qui serait plus simple et optimisé
cheez moi ca marche
[php]$str1 = '>B_1 7.500 750 pos. 136 - 145 1D8E:B';
$str2 = '>BAB78:C_4 3.200 320 pos. 346 - 355 1';
preg_match('/^(?:.(?<!\s))+\s((?:.(?<!\s))+)\s/', $str1, $matches1);
preg_match('/^(?:.(?<!\s))+\s((?:.(?<!\s))+)\s/', $str2, $matches2);
var_dump($matches1, $matches2);[/php]
[code]array(2) {
[0]=>
string(11) ">B_1 7.500 "
[1]=>
string(5) "7.500"
}
array(2) {
[0]=>
string(17) ">BAB78:C_4 3.200 "
[1]=>
string(5) "3.200"
}[/code]
sinon tu fais un [url=http://php.net/manual/fr/function.explode.php]explode[/url], qui serait plus simple et optimisé