Como analisar cada resposta usando regex

0

Pergunta

Alguém pode me ajudar a analisar essas mensagens? Estas respostas são de uma conexão de soquete TCP em uma contração canal de bate-papo. Às vezes, as respostas são de uma mensagem, às vezes vários, especialmente na agitada canais. Abaixo você pode ver 1 resposta usando a resposta "a" - - -". As 3 primeiras respostas, 2 mensagens, os três têm 1, e os dois têm vários.

Response ----  :[email protected] PRIVMSG #xqcow :ring them up
:[email protected] PRIVMSG #xqcow :karma for laughing at the dancing guy FeelsBadMan

Response ----  :[email protected] PRIVMSG #xqcow :!emotes bttv
:[email protected] PRIVMSG #xqcow :CiGrip

Response ----  :[email protected] PRIVMSG #xqcow :H H H H H H
:[email protected] PRIVMSG #xqcow :OMEGALUL

Response ----  :koolaidjammer__!koolaidjammer__@koolaidjammer__.tmi.twitch.tv PRIVMSG #xqcow :xqcHead xqcHead xqcHead

Response ----  :its_physikz!its_physikz@its_physikz.tmi.twitch.tv PRIVMSG #xqcow :xqcSus BLOW PIPES?

Response ----  :syon_!syon_@syon_.tmi.twitch.tv PRIVMSG #xqcow :CiGrip ONLY 40?

Response ----  :[email protected] PRIVMSG #xqcow :MARIJUANA
:choomoo__!choomoo__@choomoo__.tmi.twitch.tv PRIVMSG #xqcow :HOW IS THERAPY BATCHEST OMEGALUL
:[email protected] PRIVMSG #xqcow :LULW
:[email protected] PRIVMSG #xqcow :CiGrip NICE
:[email protected] PRIVMSG #xqcow :H GG

Response ----  :tnr_gio!tnr_gio@tnr_gio.tmi.twitch.tv PRIVMSG #xqcow :mothakeeeeee
:[email protected] PRIVMSG #xqcow :xqKaren IM STRESSIN BRUH
:logic_al!logic_al@logic_al.tmi.twitch.tv PRIVMSG #xqcow :i'll smoke to that
:[email protected] PRIVMSG #xqcow :madafeh PepegaPls madh PepegaPls madafuPepegaPls madaPepegaPls mada PepegaPls
:[email protected] PRIVMSG #xqcow :FeelsBadMan

Eu estava pensando em como cada uma mensagem de resposta tem dois ":" eu estava pensando em separar a seqüência de caracteres a cada dois ":" usando expressões regulares. Qualquer ajuda é bem-vinda

python regex
2021-11-24 05:52:54
1

Melhor resposta

0

Você pode usar simples str métodos

spam = """Response ----  :[email protected] PRIVMSG #xqcow :ring them up
:[email protected] PRIVMSG #xqcow :karma for laughing at the dancing guy FeelsBadMan

Response ----  :[email protected] PRIVMSG #xqcow :!emotes bttv
:[email protected] PRIVMSG #xqcow :CiGrip

Response ----  :[email protected] PRIVMSG #xqcow :H H H H H H
:[email protected] PRIVMSG #xqcow :OMEGALUL

Response ----  :koolaidjammer__!koolaidjammer__@koolaidjammer__.tmi.twitch.tv PRIVMSG #xqcow :xqcHead xqcHead xqcHead

Response ----  :its_physikz!its_physikz@its_physikz.tmi.twitch.tv PRIVMSG #xqcow :xqcSus BLOW PIPES?

Response ----  :syon_!syon_@syon_.tmi.twitch.tv PRIVMSG #xqcow :CiGrip ONLY 40?

Response ----  :[email protected] PRIVMSG #xqcow :MARIJUANA
:choomoo__!choomoo__@choomoo__.tmi.twitch.tv PRIVMSG #xqcow :HOW IS THERAPY BATCHEST OMEGALUL
:[email protected] PRIVMSG #xqcow :LULW
:[email protected] PRIVMSG #xqcow :CiGrip NICE
:[email protected] PRIVMSG #xqcow :H GG

Response ----  :tnr_gio!tnr_gio@tnr_gio.tmi.twitch.tv PRIVMSG #xqcow :mothakeeeeee
:[email protected] PRIVMSG #xqcow :xqKaren IM STRESSIN BRUH
:logic_al!logic_al@logic_al.tmi.twitch.tv PRIVMSG #xqcow :i'll smoke to that
:[email protected] PRIVMSG #xqcow :madafeh PepegaPls madh PepegaPls madafuPepegaPls madaPepegaPls mada PepegaPls
:[email protected] PRIVMSG #xqcow :FeelsBadMan
"""


for response in spam.replace('Response ----  ', '').split('\n\n'):
    print(response.strip().splitlines())

você receberá mensagens em cada resposta, como listas. Você pode trabalhar a partir daqui se você não se importa se a mensagem veio de resposta diferente

2021-11-24 06:12:49

Em outros idiomas

Esta página está em outros idiomas

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................