Come analizzare ogni risposta usando l'espressione regolare

0

Domanda

Qualcuno mi può aiutare per l'analisi di questi messaggi? Queste risposte sono da una connessione socket TCP in una contrazione del canale di chat. A volte le risposte sono di un messaggio, a volte di più, soprattutto nella frenetica canali. Qui di seguito potete vedere 1 risposta mediante risposta" - - -". Le prime 3 risposte, ha 2 messaggi, dopo tre anni sono 1 e le due successive sono più.

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

Stavo pensando dato che ogni messaggio in una risposta ha due ":" stavo pensando di separare la stringa ogni due ":" usando l'espressione regolare. Ogni aiuto è apprezzato

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

Migliore risposta

0

È possibile utilizzare una semplice str metodi

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())

ottenere i messaggi in ciascuna risposta in forma di elenco. Si può lavorare da qui se non si cura se il messaggio proviene da differenti risposta

2021-11-24 06:12:49

In altre lingue

Questa pagina è in altre lingue

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