Feature(custom): add u flag for gallery regexp match

This commit is contained in:
Kuingsmile 2024-04-04 09:10:41 +08:00
parent 0476346070
commit aa9e535fd1

View File

@ -182,7 +182,7 @@ export const svg = `
export function customStrMatch (str: string, pattern: string) : boolean { export function customStrMatch (str: string, pattern: string) : boolean {
if (!str || !pattern) return false if (!str || !pattern) return false
try { try {
const reg = new RegExp(pattern, 'g') const reg = new RegExp(pattern, 'ug')
return reg.test(str) return reg.test(str)
} catch (e) { } catch (e) {
console.error(e) console.error(e)
@ -195,7 +195,7 @@ export function customStrReplace (str: string, pattern: string, replacement: str
replacement = replacement || '' replacement = replacement || ''
let result = str let result = str
try { try {
const reg = new RegExp(pattern, 'g') const reg = new RegExp(pattern, 'ug')
result = str.replace(reg, replacement) result = str.replace(reg, replacement)
result = renameFileNameWithCustomString(result, result, str) result = renameFileNameWithCustomString(result, result, str)
} catch (e) { } catch (e) {