正向预查,我们假设需要仅匹配 Windows,不匹配后面的版本号,并且要求 Windows 后面的版本号只能是 数字类型,换言之,XP 和 Vista 不能被匹配
$str="Windows 1.03 and Windows 2.0 fisrt Released in 1985 and 1987 respectively.Windows 95 and Windows 98 are the successor.Then Windows 2000 and Windows Xp appeared.Windows Vista is the Latest version of the family.";$pattern="/Windows(?=[\s]+[\d\.]+)/";preg_match_all($pattern,$str,$matches);echo'<pre>';var_dump($matches);