How to extract all matches from a string using single regular expression in PHP?

Viewed 2295

I want to insert all matched patterns into a single array using a regular expression in PHP.

For example, I have following text:

calculated F 1a5 5W13 153w135 1E55 12_5 1.56 1M55

My php code is like this:

$txt="calculated 1a5 5W13 153w135 1E55 12_5 1.56 1M55";
preg_match_all("/calculated F( ([\d\w_\.]+))+/s",$txt,$matches);
print_r($matches);

I need somethings like as:

Array ( [0] =>1a5, [1]=> 5W13, [2]=>  153w135, [3]=>  1E55, [4]=>  12_5, [5]=>  1.56, [6]=> 1M55)
3 Answers
Related