例如,如果有像ღ,❤等字符,有没有办法可以从python中的字符串中删除它们?我不想添加一个删除所有非英语字符的过滤器,因为可能还有其他有意义的语言。
答案 0 :(得分:0)
所有Unicode 10个人表情符号的正则表达式,不包括拉丁字符
如果您需要匹配系列,请执行以下操作:
01F468 MAN
01F3FB EMOJI MODIFIER FITZPATRICK TYPE-1-2
00200D ZERO WIDTH JOINER
002695 ⚕ STAFF OF AESCULAPIUS
00FE0F ️ VARIATION SELECTOR-16
使用正则表达式将单个表情符号与已知系列组合使用 适当的木匠和/或变体选择器。
测试文件:http://unicode.org/Public/emoji/5.0/emoji-test.txt
使用ICU属性
\p{Emoji=Yes}
(?<!
[\p{Block=Basic_Latin}\p{Block=Latin_1_Supplement}\p{Block=Latin_Extended_A}\p{Block=Latin_Extended_Additional}\p{Block=Latin_Extended_B}\p{Block=Latin_Extended_C}\p{Block=Latin_Extended_D}\p{Block=Latin_Extended_E}\p{Script=Latin}]
)
使用代码点Utf-32
\ x {DDDDDD}符号
https://regex101.com/r/ARW0q4/1(Pcre)
[\x{203c}\x{2049}\x{2122}\x{2139}\x{2194}-\x{2199}\x{21a9}-\x{21aa}\x{231a}-\x{231b}\x{2328}\x{23cf}\x{23e9}-\x{23f3}\x{23f8}-\x{23fa}\x{24c2}\x{25aa}-\x{25ab}\x{25b6}\x{25c0}\x{25fb}-\x{25fe}\x{2600}-\x{2604}\x{260e}\x{2611}\x{2614}-\x{2615}\x{2618}\x{261d}\x{2620}\x{2622}-\x{2623}\x{2626}\x{262a}\x{262e}-\x{262f}\x{2638}-\x{263a}\x{2640}\x{2642}\x{2648}-\x{2653}\x{2660}\x{2663}\x{2665}-\x{2666}\x{2668}\x{267b}\x{267f}\x{2692}-\x{2697}\x{2699}\x{269b}-\x{269c}\x{26a0}-\x{26a1}\x{26aa}-\x{26ab}\x{26b0}-\x{26b1}\x{26bd}-\x{26be}\x{26c4}-\x{26c5}\x{26c8}\x{26ce}-\x{26cf}\x{26d1}\x{26d3}-\x{26d4}\x{26e9}-\x{26ea}\x{26f0}-\x{26f5}\x{26f7}-\x{26fa}\x{26fd}\x{2702}\x{2705}\x{2708}-\x{270d}\x{270f}\x{2712}\x{2714}\x{2716}\x{271d}\x{2721}\x{2728}\x{2733}-\x{2734}\x{2744}\x{2747}\x{274c}\x{274e}\x{2753}-\x{2755}\x{2757}\x{2763}-\x{2764}\x{2795}-\x{2797}\x{27a1}\x{27b0}\x{27bf}\x{2934}-\x{2935}\x{2b05}-\x{2b07}\x{2b1b}-\x{2b1c}\x{2b50}\x{2b55}\x{3030}\x{303d}\x{3297}\x{3299}\x{1f004}\x{1f0cf}\x{1f170}-\x{1f171}\x{1f17e}-\x{1f17f}\x{1f18e}\x{1f191}-\x{1f19a}\x{1f1e6}-\x{1f1ff}\x{1f201}-\x{1f202}\x{1f21a}\x{1f22f}\x{1f232}-\x{1f23a}\x{1f250}-\x{1f251}\x{1f300}-\x{1f321}\x{1f324}-\x{1f393}\x{1f396}-\x{1f397}\x{1f399}-\x{1f39b}\x{1f39e}-\x{1f3f0}\x{1f3f3}-\x{1f3f5}\x{1f3f7}-\x{1f4fd}\x{1f4ff}-\x{1f53d}\x{1f549}-\x{1f54e}\x{1f550}-\x{1f567}\x{1f56f}-\x{1f570}\x{1f573}-\x{1f57a}\x{1f587}\x{1f58a}-\x{1f58d}\x{1f590}\x{1f595}-\x{1f596}\x{1f5a4}-\x{1f5a5}\x{1f5a8}\x{1f5b1}-\x{1f5b2}\x{1f5bc}\x{1f5c2}-\x{1f5c4}\x{1f5d1}-\x{1f5d3}\x{1f5dc}-\x{1f5de}\x{1f5e1}\x{1f5e3}\x{1f5e8}\x{1f5ef}\x{1f5f3}\x{1f5fa}-\x{1f64f}\x{1f680}-\x{1f6c5}\x{1f6cb}-\x{1f6d2}\x{1f6e0}-\x{1f6e5}\x{1f6e9}\x{1f6eb}-\x{1f6ec}\x{1f6f0}\x{1f6f3}-\x{1f6f8}\x{1f910}-\x{1f93a}\x{1f93c}-\x{1f93e}\x{1f940}-\x{1f945}\x{1f947}-\x{1f94c}\x{1f950}-\x{1f96b}\x{1f980}-\x{1f997}\x{1f9c0}\x{1f9d0}-\x{1f9e6}]
\ uDDDD表示法
(需要Dot-Net进行测试)
[\u203c\u2049\u2122\u2139\u2194-\u2199\u21a9-\u21aa\u231a-\u231b\u2328\u23cf\u23e9-\u23f3\u23f8-\u23fa\u24c2\u25aa-\u25ab\u25b6\u25c0\u25fb-\u25fe\u2600-\u2604\u260e\u2611\u2614-\u2615\u2618\u261d\u2620\u2622-\u2623\u2626\u262a\u262e-\u262f\u2638-\u263a\u2640\u2642\u2648-\u2653\u2660\u2663\u2665-\u2666\u2668\u267b\u267f\u2692-\u2697\u2699\u269b-\u269c\u26a0-\u26a1\u26aa-\u26ab\u26b0-\u26b1\u26bd-\u26be\u26c4-\u26c5\u26c8\u26ce-\u26cf\u26d1\u26d3-\u26d4\u26e9-\u26ea\u26f0-\u26f5\u26f7-\u26fa\u26fd\u2702\u2705\u2708-\u270d\u270f\u2712\u2714\u2716\u271d\u2721\u2728\u2733-\u2734\u2744\u2747\u274c\u274e\u2753-\u2755\u2757\u2763-\u2764\u2795-\u2797\u27a1\u27b0\u27bf\u2934-\u2935\u2b05-\u2b07\u2b1b-\u2b1c\u2b50\u2b55\u3030\u303d\u3297\u3299\U0001f004\U0001f0cf\U0001f170-\U0001f171\U0001f17e-\U0001f17f\U0001f18e\U0001f191-\U0001f19a\U0001f1e6-\U0001f1ff\U0001f201-\U0001f202\U0001f21a\U0001f22f\U0001f232-\U0001f23a\U0001f250-\U0001f251\U0001f300-\U0001f321\U0001f324-\U0001f393\U0001f396-\U0001f397\U0001f399-\U0001f39b\U0001f39e-\U0001f3f0\U0001f3f3-\U0001f3f5\U0001f3f7-\U0001f4fd\U0001f4ff-\U0001f53d\U0001f549-\U0001f54e\U0001f550-\U0001f567\U0001f56f-\U0001f570\U0001f573-\U0001f57a\U0001f587\U0001f58a-\U0001f58d\U0001f590\U0001f595-\U0001f596\U0001f5a4-\U0001f5a5\U0001f5a8\U0001f5b1-\U0001f5b2\U0001f5bc\U0001f5c2-\U0001f5c4\U0001f5d1-\U0001f5d3\U0001f5dc-\U0001f5de\U0001f5e1\U0001f5e3\U0001f5e8\U0001f5ef\U0001f5f3\U0001f5fa-\U0001f64f\U0001f680-\U0001f6c5\U0001f6cb-\U0001f6d2\U0001f6e0-\U0001f6e5\U0001f6e9\U0001f6eb-\U0001f6ec\U0001f6f0\U0001f6f3-\U0001f6f8\U0001f910-\U0001f93a\U0001f93c-\U0001f93e\U0001f940-\U0001f945\U0001f947-\U0001f94c\U0001f950-\U0001f96b\U0001f980-\U0001f997\U0001f9c0\U0001f9d0-\U0001f9e6]
代码点范围(Utf-32)
Basic
-------------------
00203c
002049
002122
002139
002194 - 002199
0021a9 - 0021aa
00231a - 00231b
002328
0023cf
0023e9 - 0023f3
0023f8 - 0023fa
0024c2
0025aa - 0025ab
0025b6
0025c0
0025fb - 0025fe
002600 - 002604
00260e
002611
002614 - 002615
002618
00261d
002620
002622 - 002623
002626
00262a
00262e - 00262f
002638 - 00263a
002640
002642
002648 - 002653
002660
002663
002665 - 002666
002668
00267b
00267f
002692 - 002697
002699
00269b - 00269c
0026a0 - 0026a1
0026aa - 0026ab
0026b0 - 0026b1
0026bd - 0026be
0026c4 - 0026c5
0026c8
0026ce - 0026cf
0026d1
0026d3 - 0026d4
0026e9 - 0026ea
0026f0 - 0026f5
0026f7 - 0026fa
0026fd
002702
002705
002708 - 00270d
00270f
002712
002714
002716
00271d
002721
002728
002733 - 002734
002744
002747
00274c
00274e
002753 - 002755
002757
002763 - 002764
002795 - 002797
0027a1
0027b0
0027bf
002934 - 002935
002b05 - 002b07
002b1b - 002b1c
002b50
002b55
003030
00303d
003297
003299
Supplemental
-------------------
01f004
01f0cf
01f170 - 01f171
01f17e - 01f17f
01f18e
01f191 - 01f19a
01f1e6 - 01f1ff
01f201 - 01f202
01f21a
01f22f
01f232 - 01f23a
01f250 - 01f251
01f300 - 01f321
01f324 - 01f393
01f396 - 01f397
01f399 - 01f39b
01f39e - 01f3f0
01f3f3 - 01f3f5
01f3f7 - 01f4fd
01f4ff - 01f53d
01f549 - 01f54e
01f550 - 01f567
01f56f - 01f570
01f573 - 01f57a
01f587
01f58a - 01f58d
01f590
01f595 - 01f596
01f5a4 - 01f5a5
01f5a8
01f5b1 - 01f5b2
01f5bc
01f5c2 - 01f5c4
01f5d1 - 01f5d3
01f5dc - 01f5de
01f5e1
01f5e3
01f5e8
01f5ef
01f5f3
01f5fa - 01f64f
01f680 - 01f6c5
01f6cb - 01f6d2
01f6e0 - 01f6e5
01f6e9
01f6eb - 01f6ec
01f6f0
01f6f3 - 01f6f8
01f910 - 01f93a
01f93c - 01f93e
01f940 - 01f945
01f947 - 01f94c
01f950 - 01f96b
01f980 - 01f997
01f9c0
01f9d0 - 01f9e6
使用代码点Utf-16
\ x {DDDD}符号
https://regex101.com/r/xxvM5J/1(Pcre)
(?:
[\x{203c}\x{2049}\x{2122}\x{2139}\x{2194}-\x{2199}\x{21a9}-\x{21aa}\x{231a}-\x{231b}\x{2328}\x{23cf}\x{23e9}-\x{23f3}\x{23f8}-\x{23fa}\x{24c2}\x{25aa}-\x{25ab}\x{25b6}\x{25c0}\x{25fb}-\x{25fe}\x{2600}-\x{2604}\x{260e}\x{2611}\x{2614}-\x{2615}\x{2618}\x{261d}\x{2620}\x{2622}-\x{2623}\x{2626}\x{262a}\x{262e}-\x{262f}\x{2638}-\x{263a}\x{2640}\x{2642}\x{2648}-\x{2653}\x{2660}\x{2663}\x{2665}-\x{2666}\x{2668}\x{267b}\x{267f}\x{2692}-\x{2697}\x{2699}\x{269b}-\x{269c}\x{26a0}-\x{26a1}\x{26aa}-\x{26ab}\x{26b0}-\x{26b1}\x{26bd}-\x{26be}\x{26c4}-\x{26c5}\x{26c8}\x{26ce}-\x{26cf}\x{26d1}\x{26d3}-\x{26d4}\x{26e9}-\x{26ea}\x{26f0}-\x{26f5}\x{26f7}-\x{26fa}\x{26fd}\x{2702}\x{2705}\x{2708}-\x{270d}\x{270f}\x{2712}\x{2714}\x{2716}\x{271d}\x{2721}\x{2728}\x{2733}-\x{2734}\x{2744}\x{2747}\x{274c}\x{274e}\x{2753}-\x{2755}\x{2757}\x{2763}-\x{2764}\x{2795}-\x{2797}\x{27a1}\x{27b0}\x{27bf}\x{2934}-\x{2935}\x{2b05}-\x{2b07}\x{2b1b}-\x{2b1c}\x{2b50}\x{2b55}\x{3030}\x{303d}\x{3297}\x{3299}]
|
# Surrogate pairs
(?:
\x{d83c} [\x{dc04}\x{dccf}\x{dd70}-\x{dd71}\x{dd7e}-\x{dd7f}\x{dd8e}\x{dd91}-\x{dd9a}\x{dde6}-\x{ddff}\x{de01}-\x{de02}\x{de1a}\x{de2f}\x{de32}-\x{de3a}\x{de50}-\x{de51}\x{df00}-\x{df21}\x{df24}-\x{df93}\x{df96}-\x{df97}\x{df99}-\x{df9b}\x{df9e}-\x{dff0}\x{dff3}-\x{dff5}\x{dff7}-\x{dfff}]
| \x{d83d} [\x{dc00}-\x{dcfd}\x{dcff}-\x{dd3d}\x{dd49}-\x{dd4e}\x{dd50}-\x{dd67}\x{dd6f}-\x{dd70}\x{dd73}-\x{dd7a}\x{dd87}\x{dd8a}-\x{dd8d}\x{dd90}\x{dd95}-\x{dd96}\x{dda4}-\x{dda5}\x{dda8}\x{ddb1}-\x{ddb2}\x{ddbc}\x{ddc2}-\x{ddc4}\x{ddd1}-\x{ddd3}\x{dddc}-\x{ddde}\x{dde1}\x{dde3}\x{dde8}\x{ddef}\x{ddf3}\x{ddfa}-\x{de4f}\x{de80}-\x{dec5}\x{decb}-\x{ded2}\x{dee0}-\x{dee5}\x{dee9}\x{deeb}-\x{deec}\x{def0}\x{def3}-\x{def8}]
| \x{d83e} [\x{dd10}-\x{dd3a}\x{dd3c}-\x{dd3e}\x{dd40}-\x{dd45}\x{dd47}-\x{dd4c}\x{dd50}-\x{dd6b}\x{dd80}-\x{dd97}\x{ddc0}\x{ddd0}-\x{dde6}]
)
)
\ uDDDD表示法
https://regex101.com/r/xxvM5J/2(JavaScript)
(?:
[\u203c\u2049\u2122\u2139\u2194-\u2199\u21a9-\u21aa\u231a-\u231b\u2328\u23cf\u23e9-\u23f3\u23f8-\u23fa\u24c2\u25aa-\u25ab\u25b6\u25c0\u25fb-\u25fe\u2600-\u2604\u260e\u2611\u2614-\u2615\u2618\u261d\u2620\u2622-\u2623\u2626\u262a\u262e-\u262f\u2638-\u263a\u2640\u2642\u2648-\u2653\u2660\u2663\u2665-\u2666\u2668\u267b\u267f\u2692-\u2697\u2699\u269b-\u269c\u26a0-\u26a1\u26aa-\u26ab\u26b0-\u26b1\u26bd-\u26be\u26c4-\u26c5\u26c8\u26ce-\u26cf\u26d1\u26d3-\u26d4\u26e9-\u26ea\u26f0-\u26f5\u26f7-\u26fa\u26fd\u2702\u2705\u2708-\u270d\u270f\u2712\u2714\u2716\u271d\u2721\u2728\u2733-\u2734\u2744\u2747\u274c\u274e\u2753-\u2755\u2757\u2763-\u2764\u2795-\u2797\u27a1\u27b0\u27bf\u2934-\u2935\u2b05-\u2b07\u2b1b-\u2b1c\u2b50\u2b55\u3030\u303d\u3297\u3299]
|
# Surrogate pairs
(?:
\ud83c [\udc04\udccf\udd70-\udd71\udd7e-\udd7f\udd8e\udd91-\udd9a\udde6-\uddff\ude01-\ude02\ude1a\ude2f\ude32-\ude3a\ude50-\ude51\udf00-\udf21\udf24-\udf93\udf96-\udf97\udf99-\udf9b\udf9e-\udff0\udff3-\udff5\udff7-\udfff]
| \ud83d [\udc00-\udcfd\udcff-\udd3d\udd49-\udd4e\udd50-\udd67\udd6f-\udd70\udd73-\udd7a\udd87\udd8a-\udd8d\udd90\udd95-\udd96\udda4-\udda5\udda8\uddb1-\uddb2\uddbc\uddc2-\uddc4\uddd1-\uddd3\udddc-\uddde\udde1\udde3\udde8\uddef\uddf3\uddfa-\ude4f\ude80-\udec5\udecb-\uded2\udee0-\udee5\udee9\udeeb-\udeec\udef0\udef3-\udef8]
| \ud83e [\udd10-\udd3a\udd3c-\udd3e\udd40-\udd45\udd47-\udd4c\udd50-\udd6b\udd80-\udd97\uddc0\uddd0-\udde6]
)
)
代码点范围(Utf-16)
Basic
-------------------
[ 203c ]
[ 2049 ]
[ 2122 ]
[ 2139 ]
[ 2194-2199 ]
[ 21a9-21aa ]
[ 231a-231b ]
[ 2328 ]
[ 23cf ]
[ 23e9-23f3 ]
[ 23f8-23fa ]
[ 24c2 ]
[ 25aa-25ab ]
[ 25b6 ]
[ 25c0 ]
[ 25fb-25fe ]
[ 2600-2604 ]
[ 260e ]
[ 2611 ]
[ 2614-2615 ]
[ 2618 ]
[ 261d ]
[ 2620 ]
[ 2622-2623 ]
[ 2626 ]
[ 262a ]
[ 262e-262f ]
[ 2638-263a ]
[ 2640 ]
[ 2642 ]
[ 2648-2653 ]
[ 2660 ]
[ 2663 ]
[ 2665-2666 ]
[ 2668 ]
[ 267b ]
[ 267f ]
[ 2692-2697 ]
[ 2699 ]
[ 269b-269c ]
[ 26a0-26a1 ]
[ 26aa-26ab ]
[ 26b0-26b1 ]
[ 26bd-26be ]
[ 26c4-26c5 ]
[ 26c8 ]
[ 26ce-26cf ]
[ 26d1 ]
[ 26d3-26d4 ]
[ 26e9-26ea ]
[ 26f0-26f5 ]
[ 26f7-26fa ]
[ 26fd ]
[ 2702 ]
[ 2705 ]
[ 2708-270d ]
[ 270f ]
[ 2712 ]
[ 2714 ]
[ 2716 ]
[ 271d ]
[ 2721 ]
[ 2728 ]
[ 2733-2734 ]
[ 2744 ]
[ 2747 ]
[ 274c ]
[ 274e ]
[ 2753-2755 ]
[ 2757 ]
[ 2763-2764 ]
[ 2795-2797 ]
[ 27a1 ]
[ 27b0 ]
[ 27bf ]
[ 2934-2935 ]
[ 2b05-2b07 ]
[ 2b1b-2b1c ]
[ 2b50 ]
[ 2b55 ]
[ 3030 ]
[ 303d ]
[ 3297 ]
[ 3299 ]
Supplemental
-------------------
Hi: [ d83c ] Lo: dc04, dccf, dd70-dd71, dd7e-dd7f, dd8e, dd91-dd9a, dde6-ddff, de01-de02, de1a, de2f, de32-de3a, de50-de51, df00-df21, df24-df93, df96-df97, df99-df9b, df9e-dff0, dff3-dff5, dff7-dfff,
Hi: [ d83d ] Lo: dc00-dcfd, dcff-dd3d, dd49-dd4e, dd50-dd67, dd6f-dd70, dd73-dd7a, dd87, dd8a-dd8d, dd90, dd95-dd96, dda4-dda5, dda8, ddb1-ddb2, ddbc, ddc2-ddc4, ddd1-ddd3, dddc-ddde, dde1, dde3, dde8, ddef, ddf3, ddfa-de4f, de80-dec5, decb-ded2, dee0-dee5, dee9, deeb-deec, def0, def3-def8,
Hi: [ d83e ] Lo: dd10-dd3a, dd3c-dd3e, dd40-dd45, dd47-dd4c, dd50-dd6b, dd80-dd97, ddc0, ddd0-dde6,