Answer the question
In order to leave comments, you need to log in
How to use regular expressions to catch links in Vkontakte?
Hello, friends. There is a text of the post in Vkontakte:
sample text, sample text, sample text, sample text. [id123456|User].
More text, sample text, sample text, sample text, sample text [club987654321|Community] , sample text, sample text, sample text.
preg_match_all('/\[(.+)\]/',$text,$found);
, it was not possible to get the desired. Answer the question
In order to leave comments, you need to log in
In general, the regular expression works: it extracts what you need ( https://regex101.com/r/yS7wI4/1 )
I suspect that you are using the preg_match_all function in a wrong way .
Such a regular expression can search even more accurately: \[((?:id|club)\d+)[|](.*)\]
( https://regex101.com/r/gS7xQ0/1 )
New regular expression:\[((?:id|club)\d+)[|]([^]]*)\]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question