繁体   English   中英

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

[英]regex in php for finding words

我想要以下示例的代码....

例....

$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.";

我搜索的单词是“设计一些大公园”

我需要搜索词中的前三十个词。 像google搜索结果页面.....

谢谢

如果您想像真正的搜索引擎一样,您可能会对Sphinx API感兴趣。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM