Answer the question
In order to leave comments, you need to log in
How to correctly compose a regular expression pattern?
In general, you need to check the url address for the VKontakte profile.
There can be (or not be) one dot, as many underscores, English letters and numbers as you like, the length of the string is from 2 to 33 characters inclusive, not counting the beginning of https://vk.com/.
I've done like this, but it doesn't work, in general.
For example, the string " https://vk.com/abc... " is considered valid.
preg_match('#^https://vk.com/[\d\D_(\.?)]{2,33}$#i', $_POST['source'])
preg_match('#^https://vk.com/[(\d)*(\D)*(\.)?(_)*]{2,33}$#i', $_POST['source'])
Answer the question
In order to leave comments, you need to log in
For example, like this:
And it's better to check for length using strlen ()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question