Comment analyser chaque réponse à l'aide de regex

0

La question

Quelqu'un peut-il m'aider à analyser ces messages? Ces réponses sont à partir d'une connexion socket TCP en une contraction du canal de chat. Parfois les réponses sont un message, parfois multiples, en particulier dans toutes les chaînes. Ci-dessous vous pouvez voir 1 réponse de à l'aide de la "réponse ---". Les 3 premières réponses ont 2 messages, les trois ont 1, et les deux ont plusieurs.

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

Je pensais depuis chaque message dans une réponse a deux ":" je pensais à la séparation de la chaîne par tous les deux ":" en utilisant les regex. Toute aide est appréciée

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

La meilleure réponse

0

Vous pouvez utiliser de simples str méthodes

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

vous obtenez des messages dans chaque réponse sous forme de listes. Vous pouvez travailler à partir d'ici, si vous n'avez pas de soins si le message est venu de réponse différente

2021-11-24 06:12:49

Dans d'autres langues

Cette page est dans d'autres langues

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