fix: fix Invalid regular expression on iOS <= 16.3
This commit is contained in:
parent
7d7a12d7d6
commit
2645b30fb3
|
@ -3,9 +3,6 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
const enRegex1 = /(?<=n)a/gi;
|
||||
const enRegex2 = /(?<=morn)ing/gi;
|
||||
const enRegex3 = /(?<=every)one/gi;
|
||||
const koRegex1 = /[나-낳]/g;
|
||||
const koRegex2 = /(다$)|(다(?=\.))|(다(?= ))|(다(?=!))|(다(?=\?))/gm;
|
||||
const koRegex3 = /(야(?=\?))|(야$)|(야(?= ))/gm;
|
||||
|
@ -15,9 +12,12 @@ export function nyaize(text: string): string {
|
|||
// ja-JP
|
||||
.replaceAll('な', 'にゃ').replaceAll('ナ', 'ニャ').replaceAll('ナ', 'ニャ')
|
||||
// en-US
|
||||
.replace(enRegex1, x => x === 'A' ? 'YA' : 'ya')
|
||||
.replace(enRegex2, x => x === 'ING' ? 'YAN' : 'yan')
|
||||
.replace(enRegex3, x => x === 'ONE' ? 'NYAN' : 'nyan')
|
||||
.replaceAll('na', 'nya')
|
||||
.replaceAll('NA', 'NYA')
|
||||
.replaceAll('morning', 'mornyan')
|
||||
.replaceAll('MORNING', 'MORNYAN')
|
||||
.replaceAll('everyone', 'everynyan')
|
||||
.replaceAll('EVERYONE', 'EVERYNYAN')
|
||||
// ko-KR
|
||||
.replace(koRegex1, match => !isNaN(match.charCodeAt(0)) ? String.fromCharCode(
|
||||
match.charCodeAt(0) + '냐'.charCodeAt(0) - '나'.charCodeAt(0),
|
||||
|
|
Loading…
Reference in New Issue