如何在 php 中搜索所有与正则表达式字符匹配的单词开头?

how to search all words starts match with regular expression character in php?

我必须在 php 中搜索具有正则表达式字符的字符串中的所有单词。我正在使用 preg_match_all('/\b.*?\b/i', $string, $matchWords);

但它会搜索不同位置的所有单词字符。

例如假设字符串是 "India is my country"。我必须搜索 i

结果应该是 "India" 和 "is"。请帮助我

这可以通过 /(?<!\w)i\w+/ 正则表达式来完成