I search a certain word in a string correctly in this way:
let text = jsonDesc.plain_text;
const product = 'Producto:';
const resultProduct = text.match(new RegExp(product + '\\s(\\w+)'))[1];
console.log( resultProduct ) // Mesa
But how can I search the string if sometimes the word is lowercase and other times uppercase?
I tried this:
var product = 'Producto:';
var productU = 'PRODUCTO:';
var resultProduct = text.match(new RegExp(product && productUpper + '\\s(\\w+)'))[1];
And:
var resultProduct = text.match(new RegExp( '^[a-zA-Z]' + product + '\\s(\\w+)'))[1];
But dont works, error:
Uncaught (in promise) TypeError: Cannot read property '1' of null at VueComponent.getAllProducts