douge3492 2014-08-13 20:11
浏览 28
已采纳

使用php在字符串中查找匹配的单词

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

  • 写回答

2条回答 默认 最新

  • dongtaigan1594 2014-08-13 20:14
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 代码的修改,添加和运行完善
  • ¥15 krpano-场景分组和自定义地图分组
  • ¥15 lammps Gpu加速出错
  • ¥15 关于PLUS模型中kapaa值的问题
  • ¥15 关于博途V17进行仿真时无法建立连接问题
  • ¥15 机器学习教材中的例题询问
  • ¥15 求.net core 几款免费的pdf编辑器
  • ¥15 为什么安装HCL 和virtualbox之后没有找到VirtualBoxHost-OnlyNetWork?
  • ¥15 C# P/Invoke的效率问题
  • ¥20 thinkphp适配人大金仓问题