replaceText
code:script.js
const replaceText = text => {
const splitPos = text.indexOf('\n\n')
const commands = text.substr(0, splitPos).split('\n').map(command => {
return { before, after }
})
let lines = text.substr(splitPos + 2).split('\n')
for (const { before, after } of commands) {
const match = before.match(new RegExp('^/(.*?)/(gimy*)$')) const reg = match ? new RegExp(match1, match2) : before lines = lines.map(line => line.replace(reg, after.replace(/\\n/g, '\n')))
}
return lines.join('\n')
}
scrapbox.PopupMenu.addButton({
title: 'replace',
onClick: replaceText
})