I'm trying to learn some basic r开发者_如何学Goegular expression and having a hard time getting it to work.
What is wrong with this?
if (preg_match("[a-zA-Z0-9]{1,}", $url)) {
It must be something to do with my technique since I can hardly get any examples to work.
PHP regular expressions have a forward slash (/) on either side of them. What you want is:
preg_match("/[a-zA-Z0-9]{1,}/", $url)
I assume you realise that this just matches any alphanumeric string, right? As an aside, I find websites like this useful for testing PHP regexps.
精彩评论