How can i replace quotes ("") in text with guillemets (« and »)?
I tried the usual method (replace with regexp) for replacing, but it turned out badly - I do not know how to determine if an opening quote or a closing quote.
How can i replace quotes ("") in text with guillemets (« and »)?
I tried the usual method (replace with regexp) for replacing, but it turned out badly - I do not know how to determine if an opening quote or a closing quote.
You can do replace with a regex - /"(.*?)"/g to replace the whole "word".
console.log(
'"word1" word2 "word3"'.replace(/"(.*?)"/g, '«$1»'))
Or
console.log(
'"word1" word2 "word3"'.replace(/"(.*?)"/g, (a, b) => `«${b}»`));