A
A
aks03vova2018-04-22 11:26:58
JavaScript
aks03vova, 2018-04-22 11:26:58

What is the correct way to write a regexp pattern?

There is a line like [какой-то|текст], you need to turn it into a link like . Which RegExp pattern would work? I can't think of any <a href="какой-то">текст</a>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nick Sdk, 2018-04-22
@aks03vova

More or less like this:

'[какой-то|текст]'.replace(/\[(.*?)\|(.*?)\]/, '<a href="$1">$2</a>');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question