_.replace()
doesn’t replacing anything in string. I tried like 5 different ways to do it but still nothing and I guess you are my last hope.
My code:
const http = require("http"); const dateformat = require("dateformat"); const Discord = require("discord.js"); module.exports = { name: 'ewangelia', description: "Wyświetla dzisiejszą ewangelię", execute(message) { const url = 'http://feed.evangelizo.org/v2/reader.php?'; // date=20201203&type=reading&content=GSP&lang=PL let formatedURL; let now = new Date(); let today = dateformat(now, 'yyyymmdd'); let author = '', content = '', temp = []; formatedURL = url+'date='+today+'&'+'type=reading&content=GSP&lang=PL'; //ewangelia // http.request(formatedURL, (response) => { var str = ''; response.on('data', function (chunk) { str += chunk; }); response.on('end', function () { content = str; let temp = content.split('<br /><br /><br />'); temp.pop(); temp[0] = temp[0].replace('<br />', ""); content = temp[0]; embed = new Discord.MessageEmbed() .setTitle('⛪ Ewangelia na dziś ⛪') .addField('📖 Ewangelia:', content); message.channel.send(embed); }); }).end(); }, };
I want to get rid of <br />
Advertisement
Answer
You need to pass a regular expression with global flag to replace all occurrence of a pattern.
const str = 'some text <br /> here is another text <br /> some text again'; console.log(str.replace(/<br />/g, ""));