开发者

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

开发者 https://www.devze.com 2023-02-16 05:47 出处:网络
This question already has answers here: How can I convert ereg expressions to preg in PHP? (4 answers) 开发者_StackOverflow
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

精彩评论

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