mirror of
https://github.com/SilenceLurker/ST-Amily2-Chat-Optimisation.git
synced 2026-06-06 18:15:50 +00:00
Update tagProcessor.js
This commit is contained in:
@@ -4,6 +4,12 @@ function extractContentByTag(xmlString, tagName) {
|
|||||||
return match ? match[1] : null;
|
return match ? match[1] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function extractFullTagBlock(xmlString, tagName) {
|
||||||
|
const regex = new RegExp(`(<${tagName}[^>]*>[\\s\\S]*?<\\/${tagName}>)`);
|
||||||
|
const match = xmlString.match(regex);
|
||||||
|
return match ? match[0] : null;
|
||||||
|
}
|
||||||
|
|
||||||
function replaceContentByTag(xmlString, tagName, newContent) {
|
function replaceContentByTag(xmlString, tagName, newContent) {
|
||||||
const regex = new RegExp(`(<${tagName}[^>]*>)[\\s\\S]*?(<\\/${tagName}>)`);
|
const regex = new RegExp(`(<${tagName}[^>]*>)[\\s\\S]*?(<\\/${tagName}>)`);
|
||||||
if (regex.test(xmlString)) {
|
if (regex.test(xmlString)) {
|
||||||
@@ -11,4 +17,5 @@ function replaceContentByTag(xmlString, tagName, newContent) {
|
|||||||
}
|
}
|
||||||
return xmlString;
|
return xmlString;
|
||||||
}
|
}
|
||||||
export { extractContentByTag, replaceContentByTag };
|
|
||||||
|
export { extractContentByTag, replaceContentByTag, extractFullTagBlock };
|
||||||
|
|||||||
Reference in New Issue
Block a user