简体   繁体   English

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

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

I have to search all words from a string with regular expression character in php.我必须在 php 中搜索带有正则表达式字符的字符串中的所有单词。 i am using preg_match_all('/\\b.*?\\b/i', $string, $matchWords) ;我正在使用preg_match_all('/\\b.*?\\b/i', $string, $matchWords) ;

but it search all words character in the different position.但它搜索不同位置的所有单词字符。

eg suppose string is "India is my country".例如假设字符串是“印度是我的国家”。 I have to search i我必须搜索我

It should result "India" and "is".它应该导致“印度”和“是”。 Please help me请帮我

这可以通过/(?<!\\w)i\\w+/ regx 来完成它会起作用

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

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