php:现有一段英文文章,中间混合有数值(整数或小数,也有可能有负数),应用正则表达式找出满足条件的字符串后输出,若有多个满足条件,每行输出一个结果。条件1:长度为4的单词 条件2:首字母大写的单词 条件3:数值
这样?
<meta charset="utf-8">
<?php
$s=<<<str
The United States will reopen in November to air travelers from 33 countries including China, India, Brazil and most of Europe who are fully vaccinated against COVID-19, the White House said on Monday, easing tough pandemic-related restrictions that started early last year.
The survey collected 5,335 questionnaires from respondents in China’s 31 provinces, autonomous regions and municipalities who have travelled outside Asia over the past three years, containing a series of information, such as people's travel willingness, the transportation modes that they prefer to take, and concerns regarding vaccine passports, among others.
12.12 -13.33 0.25
str;
preg_match_all('/\b[A-Z][a-zA-Z]+|\b[a-zA-Z]{4}\b|-?\d\d{0,2}(,\d{3})*(\.\d+)?/',$s,$matches);
foreach($matches[0] as $item)
echo $item.'<br>';
?>