whenever I run the code below I get en error TypeError: responseData.matchAll is not a function
var responseData = response.data.toString();
var regex = new RegExp('(<dbname>)(.*?)(?=<\/dbname>)', 'g');
var matches = responseData.matchAll(regex);
When I replace matchAll with exec it works! However, I need to use matchAll. This is driving me crazy. Thanks
If you need matchAll, use it if supported:
var responseData = "<dbname>hhh</dbname>hhh<dbname>hhh3</dbname>";
var regex = new RegExp('<dbname>(.*?)(?=</dbname>)', 'g');
console.log(Array.from(responseData.matchAll(regex), x=>x[1]));
// => ["hhh","hhh3"]
You can also use exec:
var responseData = "<dbname>hhh</dbname>hhh<dbname>hhh3</dbname>";
var regex = new RegExp('<dbname>(.*?)(?=</dbname>)', 'g');
while(match=regex.exec(responseData)){
console.log(match[1]);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With