I need the character '\' (Reverse Solidus) to be included with the value of the captured group.
Example:
In the sentence assets / pdf / regulation_demais_ddds_ Hi Mod.pdf , I need the excerptbe replaced by
\/pdf\/
forming the phrase
assets\/pdf\/regulamento_demais_ddds_Oi_Mod.pdf
Regular expression working: link
Example Code:
//Expressão regular aplicada
(\/(?=pdf|images)pdf|\/images)
//Texto para achar o grupo de substituição
const texto = 'assets/pdf/regulamento_Oi_Mod.pdf assets/images/oi-mod-tela-controle-2x.gif'
const resultado = texto.replace(/(\/(?=pdf|images)pdf|\/images)/g, '/\\/');//Replace para incluir '\' no valor capturado
The problem is that the character '\' is not recognized.
Code:
//Texto para achar o grupo de substituição
const texto = 'assets/pdf/regulamento_Oi_Mod.pdf assets/images/oi-mod-tela-controle-2x.gif'
//Replace para incluir '\' no valor capturado
const resultado = texto.replace(/(\/(?=pdf|images)pdf|\/images)/g, '/\\/');
console.log(resultado)