1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 匹配表情emoji 正则 在python正则表达式中匹配unicode表情符号

匹配表情emoji 正则 在python正则表达式中匹配unicode表情符号

时间:2024-05-07 20:21:28

相关推荐

匹配表情emoji 正则 在python正则表达式中匹配unicode表情符号

I need to extract the text between a number and an emoticon in a text

example text:

blah xzuyguhbc ibcbb bqw 2 extract1 ☺️ jbjhcb 6 extract2 ???? bjvcvvv

output:

extract1

extract2

The regex code that I wrote extracts the text between 2 numbers, I need to change the part where it identifies the unicode emoji characters and extracts text between them.

(?<=[\s][\d])(.*?)(?=[\d])

Please suggest a python friendly method, and I need it to work with all the emojis not only the ones given in the example

解决方案

Since there are a lot of emoji with different unicode values, you have to explicitly specify them in your regex, or if they are with a spesific range you can use a character class. In this case your second simbol is not a standard emoji, its just a unicode character, but since its great

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。