I have a string that has been parsed from an XML page:
var data = '<Message>Fermata 1431 - Linea 202 -> 08:57 Linea 201 -> 09:02 Linea 256B -> 09:02 Linea 202 -> 09:05 Linea R2 -> 09:06 Linea 201 -> 09:13 Linea 201 -> 09:18</Message>'
I am trying to remove the <Message> tags using pure JavaScript with the following code:
data = data.replace(/<\/?Message>/g, '');
However, I am still seeing the Message tags displayed. It seems like my regular expression is not correct.
Ultimately, I need to display the following information using only pure JavaScript without jQuery:
202 at 08:57
201 at 09:02
256B at 09:02
202 at 09:05
R2 at 09:06
201 at 09:13
201 at 09:18
In PHP, I was able to achieve this with the following code. Now, I need to convert it to JavaScript:
var scraped_data = data.match(/<Message>(.*?)<\/Message>/)[1];
var parts = scraped_data.split('Linea');
for (var i = 1; i < parts.length; i++) {
console.log('<p>Linea ' + parts[i].replace('->', 'at') + '</p>');
}