开发者

ereg() to preg_match() how? [duplicate]

This question already has answers here: How can I convert ereg expressions to preg in PHP? (4 answers) 开发者_StackOverflow Closed 3 years ago.

I have kind of simple regexes that i am using.

It's so simple as:

"user/"
"user/[A-z0-9_-]"

These all work fine with ereg, but not preg.

How to convert it?

Thanks


It's most probably because your're missing the delimiters. Try this:

"~user/~"
"~user/[A-z0-9_-]~"


ereg('jpg$', $query)

Turns into:

preg_match('@jpg$@', $query)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜