我有一个大字符串,超过1000个单词。我需要的是找到某个单词,然后将一些单词包含在变量中。查找字符串中的某个单词,然后环绕它
$in = 'This is a very long sentence, what I need is to find the word "phone" in this sentence, and after that, to wrap some words around it';
如何实现这一点:
$out = 'find the word "phone" in this sentence';
所以,你可以看到,当我找到单词“手机”,我想这个词的左向右&扩大。 一个真实的例子是,当您在google上查询标题结果时,您会从网页获取一些内容,并且查询以粗体显示。
您的匹配有多模糊?精确匹配,还是与词干和这样的规范化?你有搜索查询的位置数据吗? –
请确定一个*词*是什么。 – hakre