增加移除规则标记末尾的中文

This commit is contained in:
onvia
2023-09-15 10:39:40 +08:00
parent 12975ba1a8
commit 963a48256a
4 changed files with 14 additions and 8 deletions

View File

@@ -1256,11 +1256,14 @@
return obj;
}
removeChineseFromEnd(inputString) {
if (!inputString) {
return inputString;
}
const chineseRegex = /[\u4e00-\u9fa5]+$/;
const match = inputString.match(chineseRegex);
const match = inputString.trim().match(chineseRegex);
if (match && match[0]) {
const chineseLength = match[0].length;
return inputString.slice(0, -chineseLength);
return this.removeChineseFromEnd(inputString.slice(0, -chineseLength));
}
return inputString;
}

View File

@@ -206,14 +206,17 @@ export abstract class PsdLayer {
return obj;
}
removeChineseFromEnd(inputString: string): string {
if (!inputString) {
return inputString;
}
const chineseRegex = /[\u4e00-\u9fa5]+$/;
const match = inputString.match(chineseRegex);
const match = inputString.trim().match(chineseRegex);
if (match && match[0]) {
const chineseLength = match[0].length;
return inputString.slice(0, -chineseLength);
return this.removeChineseFromEnd(inputString.slice(0, -chineseLength));
}
return inputString;
}
/** 解析数据 */