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?

2

1 Answer 1

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
}
Sign up to request clarification or add additional context in comments.

5 Comments

awesome, but partner and token can be numeric, alpha (uppercase and lowercase).
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.
it can be: a-z, A-Z, 0-9
@mateuszji you should update the question so it reflects what you actually were trying to do.
I just edited the question for him to reflect the outcome

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.