代码之家  ›  专栏  ›  技术社区  ›  Paul M

Eregi到pregèu替换php 5.3兼容性的更改

  •  0
  • Paul M  · 技术社区  · 16 年前

    我的一个脚本中有一行代码,它抛出了一个不推荐的错误。

     eregi_replace( '\.([a-z]{3,4})$', "-{$width}x{$height}.\\1", $src );
    

    有人能告诉我怎么把这个变成 preg_replace

    它是否像单纯地替换 eregi_replace 具有 preg\ U更换

    我讨厌正则表达式:)

    1 回复  |  直到 13 年前
        1
  •  3
  •   Gumbo    16 年前

    delimiters / i modifier :

    /\.([a-z]{3,4})$/i
    

    所以:

    preg_replace('/\.([a-z]{3,4})$/i', "-{$width}x{$height}.\\1", $src);
    

    看到这个了吗 manual page for the differences between POSIX ERE and PCRE