代码之家  ›  专栏  ›  技术社区  ›  Eric

php preg_替换iOS撇号

  •  1
  • Eric  · 技术社区  · 6 年前

    如何使用php替换iOS撇号 preg_替换 ?

    我试过了

    preg_replace("/(\u2019)/", '-', $mytring); //Compilation failed: PCRE does not support \L, \l, \N{name}, \U, or \u
    
    preg_replace("/(’)/", '-', $mytring); //Not working
    

    preg_replace("/(\x{2019})/u", '-', 'it’s'); //it’s
    

    但我在窗户上,有关系吗?

    编辑: 好的,现在可以工作了,我必须先对它进行html实体解码,然后从转储文件中看不到它。感谢那些回答的人。

    2 回复  |  直到 6 年前
        1
  •  1
  •   AymDev    6 年前

    你可以抓住 使用 \x{xx} 使用 /u modifier PCRE U UTF8型

    preg_replace('/\x{2019}/u', "'", $mytring);
    
        2
  •  1
  •   L McClean    6 年前

    你应该可以这样做:

    $result = preg_replace('/\x{2019}/u',"-", $mytring);
    

    here