Eregi 对 preg_replace 进行更改以实现 php 5.3 兼容性
我的一个脚本中有这一行,它抛出了一个已弃用的错误。
eregi_replace( '\.([a-z]{3,4})$', "-{$width}x{$height}.\\1", $src );
有人可以告诉我如何将其转换为 preg_replace
并告诉我原因以及需要更改哪些部分,以便我可以了解未来的更改吗?我自己也尝试过,但是这段代码在哪里意味着它真的很难测试!
是否像纯粹用 preg_replace
替换 eregi_replace
一样简单?
我讨厌正则表达式:)
I have this line in one of my scripts and its throwing a deprecated error.
eregi_replace( '\.([a-z]{3,4})
Can someone show me how to turn this into preg_replace
and tell me why and which bits of it need to change so I can learn for future changes? I have had a go myself but where this bit of code is means its really hard to test!!
Is it as simple as purely replacing the eregi_replace
with preg_replace
?
I hate regular expressions :)
, "-{$width}x{$height}.\\1", $src );
Can someone show me how to turn this into preg_replace
and tell me why and which bits of it need to change so I can learn for future changes? I have had a go myself but where this bit of code is means its really hard to test!!
Is it as simple as purely replacing the eregi_replace
with preg_replace
?
I hate regular expressions :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要 分隔符,例如
/
和 i 修饰符:所以:
请参阅此 POSIX ERE 和 PCRE 之间差异的手册页。
You need delimiters like
/
and the i modifier:So:
See this manual page for the differences between POSIX ERE and PCRE.