Match unicode emoji in python regex

前端 未结 3 1165
时光说笑
时光说笑 2021-01-18 02:49

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          


        
3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-18 03:15

    So this may or not work depending on your needs. If you know the emoji's ahead of time though this will probably work, you just need a list of the types of emoticons to expect.

    Anyway without more information, this is what I'd do.

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    
    import re
    
    my_regex = re.compile(r'\d\s*([^☺️|^

提交回复
热议问题