Nitin Karale
Nitin Karale

Reputation: 799

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. i am using preg_match_all('/\b.*?\b/i', $string, $matchWords);

but it search all words character in the different position.

e.g suppose string is "India is my country". I have to search i

It should result "India" and "is". Please help me

Upvotes: 1

Views: 96

Answers (1)

Parth Chavda
Parth Chavda

Reputation: 1829

this can be done by the /(?<!\w)i\w+/ regx it will work

Upvotes: 1

Related Questions