Forgot password?
 Register account
View 178|Reply 1

Emoji替换為黑白的

[Copy link]

3153

Threads

7906

Posts

610K

Credits

Credits
64096
QQ

Show all posts

hbghlyj Posted 2024-2-10 19:51 |Read mode
将字符串中的Emoji替换為黑白的。例如:
1+1=3? ❌
2+2=3? ❌
Javascript:'1+1=3? ❌\n2+2=3? ❌'.replace(/\p{Emoji}/gu,'$&\uFE0E')
输出
1+1=3? ❌︎
2+2=3? ❌︎

developer.mozilla.org/en-US/docs/Web/CSS/font-variant-emoji

3153

Threads

7906

Posts

610K

Credits

Credits
64096
QQ

Show all posts

 Author| hbghlyj Posted 2024-2-10 20:15
\p{Emoji}把數字0-9也匹配了,應該用\p{Extended_Pictographic}
stackoverflow.com/questions/64389323/why-do-u … scapes-match-numbers

Mobile version|Discuz Math Forum

2025-6-5 01:09 GMT+8

Powered by Discuz!

× Quick Reply To Top Edit