0

i want to search matching word in string like if i have a string

"i'm expert in ..."
"i have exposure "

if i search "exp" i should return "expert" from first string and "exposure" from second string, if i search "exper" than i should just return "expert" or other words starting "exper"

i'm not looking for position of word but return searched word with in string

i have looked for this all i found strstr(),strrpos() and some others but not what i'm looking for and i'm unable to get it working

3
  • Should it return 'inexpert'? Commented Aug 13, 2014 at 20:13
  • start with preg_match()
    – user557846
    Commented Aug 13, 2014 at 20:14
  • No,expenditure,experiment if i search "expe"
    – Yasir
    Commented Aug 13, 2014 at 20:15

2 Answers 2

2

You can find all the words starting with exp using pre_match or preg_match_all and the regex:

/(exp\w*)/g

You can test it here.

0
0

Very similar to enrico:

/(exp\w+)/gi

here http://regex101.com/r/xO9eR7/1

Not the answer you're looking for? Browse other questions tagged or ask your own question.