if you only need to handle numeric type, I'd recommend regular expressions:
strng = ' 2 blue birds and 4 red birds';
res_str = regexp(strng,'\d+(\.\d+)?','match');
res_num = str2double(res_str);
If you also want to handle written numbers as in your initial example
'there are two blue birds and 4 red birds on the branch'
this FEX might by of great help.