Jump to content

need a little help


dezkit

Recommended Posts

Hey guys I'm trying to do so that it checks if a string has something like

 

http://steamcommunity.com/id/XXXXXXX

http://steamcommunity.com/profiles/YYYYYYYYYY

 

where X can equal numbers and letters

and where Y can equal a numbers

 

I currently have

if(preg_match("/^http://steamcommunity.com/id/[a-zA-Z0-9]/",$str)){
echo "match found 3";
}

But it doesn't work gives me error

Warning: preg_match() [function.preg-match]: Unknown modifier '/' in C:\xampp\htdocs\steamid.php on line 13

Link to comment
Share on other sites

If you are going to be checking against paths of any kind I would highly recommend not using a forward slash as your delimiter as otherwise you will need to escape every instances of it in your pattern. You also need to escape the . in your pattern. I'd also guess that since you say X can equal 'numbers and letters' i.e. plurals, that you need a quantifier to make the capture group match more than one character.

 

if(preg_match("~^http://steamcommunity\.com/id/[a-zA-Z0-9]+~",$str)){
echo "match found 3";
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.