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 vc6.0中想运行代码的时候总是提示无法打开文件是怎么回事
  • ¥25 关于##爬虫##的问题,如何解决?:
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题