0

I have structure of URL like this: https://steamcommunity.com/tradeoffer/new/?partner=12a3456asdf789&token=12345Dasdew678

The two parameters of the URL, partner and token will have dynamic values which can contain alphanumeric characters only.

I would like to know if the format of the URL meets my requirements

if($URLisFormattedProperly) {
    return true;
} else {
    return false;
}

How should I do this?

skrilled
  • 5,350
  • 2
  • 26
  • 48
mateuszji
  • 67
  • 1
  • 10

1 Answers1

1

Here you go, regex based on your existing URL

preg_match('/https\:\/\/steamcommunity\.com\/tradeoffer\/new\/\?partner=([a-zA-Z0-9]+)&token=([a-zA-Z0-9]+)/', $url, $matches);
if(count($matches)>0) 
{
    // this meets your criteria
}
skrilled
  • 5,350
  • 2
  • 26
  • 48
  • awesome, but partner and token can be numeric, alpha (uppercase and lowercase). – mateuszji Mar 25 '16 at 19:09
  • 2
    What symbols? It would be much easier to help you if you didn't modify your question as we go... Next time you ask a question, remember that these specifics matter... we're taking time out of our day to help you, we should not have to jump through hoops to help you. – skrilled Mar 25 '16 at 19:10
  • it can be: a-z, A-Z, 0-9 – mateuszji Mar 25 '16 at 19:11
  • 1
    @mateuszji you should update the question so it reflects what you actually were trying to do. – chris85 Mar 25 '16 at 19:15
  • I just edited the question for him to reflect the outcome – skrilled Mar 25 '16 at 19:16