3

I want to explode some test with first number (integer) in it . Here are some words .

Avant Browser 2013 Build 110

Firefox 23.0 Beta 10

Google Chrome 29.0.1547.41 Beta

i am trying this but its not working.

$in ='Avant Browser 2013 Build 110';

preg_match("/\d[^A-Za-z]+([A-Za-z\s]+)/", $in, $match);

echo $match[0];

Output needed is :-

Avant Browser

Firefox

Google Chrome

Please help

4

3 回答 3

4

试试这个正则表达式:

^.*?(?=\d)    //start lookup from linestart, get all symbols before first number occurance
于 2013-08-03T08:54:04.003 回答
4

试试这个正则表达式:

^[^0-9]+    // get all non-numeric character and stop when it meets numeric character..
于 2013-08-03T08:58:28.667 回答
2

这里使用 preg_match_all

$txt =<<<EOT
Avant Browser 2013 Build 110
Firefox 23.0 Beta 10
Google Chrome 29.0.1547.41 Beta
EOT;

preg_match_all('/^([^0-9]*)/m',$txt,$match);

var_dump($match);
于 2013-08-03T08:58:09.477 回答