一行多次替换

问题描述

我有一个代码,我想在此代码中进行多个替换。我的代码在这里;

/* Codded by @phaticusthiccy
Telegram: t.me/phaticusthiccy
Instagram: www.instagram.com/kyrie.baran
*/

const Asena = require('../events');
const {MessageType,MessageOptions,Mimetype} = require('@adiwajshing/baileys');
const axios = require('axios');

Asena.addCommand({pattern: 'carbon ?(.*)',fromMe: true},(async (message,match) => {

    if (match[1] === '') return await message.sendMessage('Need Word!');

    var respoimage = await axios.get(`https://carbonNowsh.herokuapp.com/?code=${match[1].replace(/#/gi,"%250A",/Ö/g,"%C3%96",/ö/g,"%C3%B6",/ü/g,"%C3%BC",/Ü/g,"%C3%9C",/Ğ/g,"%C4%9E",/ğ/g,"%C4%9F",/ş/g,"%C5%9F",/Ş/g,"%C5%9E",/ç/g,"%C3%A7",/Ç/g,"%C3%87")}&theme=blackboard&exportSize=3x&paddingVertical=200px&paddingHorizontal=200px&language=JavaScript`,{ responseType: 'arraybuffer' })

    await message.sendMessage(Buffer(respoimage.data),MessageType.image,{mimetype: Mimetype.png})

}));

哪里出错了?

.replace(/character/g,"new_character"...

如何在一行中使用多个替换??

解决方法

您应该检查 encodeURI

而不是使用正则表达式