const text = "Invalid student parameters. Error: Student stage \\\"patata\\\" is not a valid stage. Valid stages [infantil, primaria, secundaria]";
// CASE 1 (matched string + regex)
const regex = /\\"(.*?)\\"/g
text.match(regex) // output: '\"patata\"'
// CASE 2 (extended output)
const regex = /\\"(.*?)\\"/
text.match(regex)
/*
output:
[
'\"patata\"',
'patata',
index: 49,
input: 'Invalid student parameters. Error: Student stage \\"patata\\" is ' +
'not a valid stage. Valid stages [infantil, primaria, secundaria]',
groups: undefined
]
*/