V
V
Vlad_isLove2018-06-01 15:33:09
Regular Expressions
Vlad_isLove, 2018-06-01 15:33:09

Need to write a regular expression that will skip a certain kind of url?

You need to write a regular expression that will only skip links of a certain format. These should be links to your Steam profile. The fact is that the user himself enters the link in the input field and can write slightly different links to the same Steam profile, for example, write the https or http protocol at the beginning or without it at all. Users have the ability to make individual links to their profile. Therefore, links to the profile can be of 2 types: 1 - standard, when the address /profiles/ and then 17 digits, 2 - individual, when the address /id/a can then have from 3 to 32 digits, characters in both registers and signs '-', '_', but there cannot be 17 digits.
Link example #1 - https://steamcommunity.com/profiles/XXXXXXXXXXXXXXXXX/
Link example #2 -https://steamcommunity.com/id/YYY/
Where XXXXXXXXXXXXXXXXX is 17 digits. Where YYY - Can be from 3 to 32 digits, Latin letters in any case, signs -, _.
Based on all this, you need a regular expression of the following format:
At the beginning https:// or http:// or nothing, then steamcommunity.com / at this place profiles or id / here, if there was profiles before, then 17 digits or if there was id , then from 3 to 32 characters /? there may or may not be a trailing / at the end.
Visual scheme for clarity:

spoiler
5b113c3ddecd5851626153.png

I don't know how to write regular expressions, and this regular expression is needed now. Help me please.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question