Answer the question
In order to leave comments, you need to log in
How to replace [ | ] to links (From VK api)?
Good afternoon. There is a string returned by the VK API. How to use regular expression to replace all occurrences [$1|$2]
with<span data-id="$1">$2</span>
Отдельное спасибо [id89083229|Ане], [id169355957|Лере], [id148334713|Маргарите], [id146667775|Насте В.] и [id137626852|Насте Н.], которые согласились сняться в этом видео!
/\[((?:club|id)[0-9]+)\|(.+)\]/
this regex. But it selects only the first occurrence, and with an error - it affects the next ones. Answer the question
In order to leave comments, you need to log in
http://www.phpliveregex.com/
Regex: \[(.*)\|(.*)\]
Regex Options: U
Replacement: <span data-id="$1">$2</span>
Отдельное спасибо [id89083229|Ане], [id169355957|Лере], [id148334713|Маргарите], [id146667775|Насте В.] и [id137626852|Насте Н.], которые согласились сняться в этом видео!
=
Отдельное спасибо <span data-id="id89083229">Ане</span>, <span data-id="id169355957">Лере</span>, <span data-id="id148334713">Маргарите</span>, <span data-id="id146667775">Насте В.</span> и <span data-id="id137626852">Насте Н.</span>, которые согласились сняться в этом видео!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question