• 请不要在回答技术问题时复制粘贴 AI 生成的内容
acoldfox
V2EX  ›  程序员

求助一个 php 问题

  •  
  •   acoldfox · Jun 8, 2016 · 2483 views
    This topic created in 3691 days ago, the information mentioned may be changed or developed.
    不太懂 V2EX 的发帖逻辑,刚刚不下小心在 水帖那里发了三四条重复帖子了

    preg_match_all("@文 @", '123 中文', $matches, PREG_OFFSET_CAPTURE);

    发现 $matches 的值是 [0=>'文',1=>6] ,有没有什么办法让返回的 6 按 字符的数量 返回 4 呢 相当于 mb_stripos('123 中文', '文')的返回结果( 4 )

    因为要全文匹配,所以不能使用 mb_stripos;使出浑身解数,百度谷歌 stackoverflow 都没找到原因,不知道有什么解决办法?
    2 replies    2016-06-08 21:02:15 +08:00
    cxbig
        1
    cxbig  
       Jun 8, 2016
    能描述下完整的需求么?
    acoldfox
        2
    acoldfox  
    OP
       Jun 8, 2016 via iPhone
    @cxbig 我要从一段中文文章(可能含有其它字符)中取含有某个关键词的所有句子,关键词前后六个字为一个句子,目前遇到的就是上面的情况,没法正确取出句子
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   921 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 21:32 · PVG 05:32 · LAX 14:32 · JFK 17:32
    ♥ Do have faith in what you're doing.