P
P
pegas2018-02-17 17:14:50
JavaScript
pegas, 2018-02-17 17:14:50

Can you help with regex?

It is necessary between two // `let str = "qwe//qwe";` to insert any text, but then this text can be replaced with another

Answer the question

In order to leave comments, you need to log in

2 answer(s)
0
0xD34F, 2018-02-17
@1PeGaS

const str = 'qwe//qwe';
const reg = /(qwe\/).*(\/qwe)/;
const replacement = 'hello, world!!';
const newStr = str.replace(reg, `$1${replacement}$2`);

A
Andrey Tsvetkov, 2018-02-17
@yellow79

let str = "qwe//qwe";
console.log(str.replace(/\/\//g, "/"+"любой текст"+"/"))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question