regular expressions emoticons

后端 未结 1 999
暖寄归人
暖寄归人 2021-01-27 05:35

I have data split into fileids. I am trying to go through the data per fileid and search for emoticons :( and :) as defined by the regex. If an emotico

相关标签:
1条回答
  • 2021-01-27 06:08

    It looks to me like your regex is working, and that m should indeed not be None.

    >>> re.search('^(:\(|:\))+$', ':)').group()
    ':)'
    >>> re.search('^(:\(|:\))+$', ':)').group()
    ':)'
    >>> re.search('^(:\(|:\))+$', ':):(').group()
    ':):('
    >>> re.search('^(:\(|:\))+$', ':)?:(').group()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AttributeError: 'NoneType' object has no attribute 'group'
    

    However, a few things are questionable to me.

    • this will only match strings that are 100% emoticons
    • is fileid really what you're searching?
    0 讨论(0)
提交回复
热议问题