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
https://forums.phpfreaks.com/topic/202602-need-a-little-help/
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
https://forums.phpfreaks.com/topic/202602-need-a-little-help/#findComment-1062164
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.