php中用于查找单词的正则表达式

php中用于查找单词的正则表达式,php,regex,Php,Regex,我需要以下示例的代码 $words = "The sculpture was selected during a design competition. After Kapoor's design was chosen, numerous technological concerns regarding the design's construction and assembly arose, in addition to concerns regarding th

我需要以下示例的代码

$words = "The sculpture was selected during a design competition. After 
    Kapoor's design was chosen, numerous technological concerns regarding 
    the design's construction and assembly arose, in addition to concerns 
    regarding the sculpture's upkeep and maintenance. Various experts were 
    consulted, some of whom believed the design could not be implemented. 
    Eventually, a feasible method was found, but the sculpture's construction 
    fell behind schedule. It was unveiled in an incomplete form during the 
    Millennium Park grand opening  celebration in 2004, before being concealed 
    again while it was completed. Cloud Gate was formally dedicated on 
    May 15, 2006, and has since gained considerable popularity, both 
    domestically and internationally.";
例如

$words = "The sculpture was selected during a design competition. After 
    Kapoor's design was chosen, numerous technological concerns regarding 
    the design's construction and assembly arose, in addition to concerns 
    regarding the sculpture's upkeep and maintenance. Various experts were 
    consulted, some of whom believed the design could not be implemented. 
    Eventually, a feasible method was found, but the sculpture's construction 
    fell behind schedule. It was unveiled in an incomplete form during the 
    Millennium Park grand opening  celebration in 2004, before being concealed 
    again while it was completed. Cloud Gate was formally dedicated on 
    May 15, 2006, and has since gained considerable popularity, both 
    domestically and internationally.";
我刚搜索到的词是“设计一些大公园”

我需要搜索词的前三十个词。像谷歌搜索结果页面


感谢使用preg_match_all,最后一个参数根据提供的模式给出结果。您可以提供一个常量字符串而不是正则表达式模式

如果你想像真正的搜索引擎那样做,你可能会感兴趣。

那么你想在“设计”、“一些”、“大”或“公园”中的任何一个之后获取
$words
中的前30个单词?所以你想要“设计比赛。在卡普尔的设计被选中后[再剪掉23个字]”?