-1

I need to split a really complex line for me. The line I want to split is as follows

2019.10.20-22.01.33: '10.11.111.25 9999995555884411:TechnoBeceT(69)' logged in

how can i split this like this

['2019.10.20-22.01.33', '10.11.111.25', '9999995555884411', 'logged in']

i don't need TechnoBeceT(69) this area.

TechnoBeceT
  • 42
  • 13
  • 1
    Welcome to SO! When you place a question try to add a minimum content: input sample, expected output sample, what did you try, research and where are you stacked. What did you try? SO is not a free coding service. – David García Bodego Oct 21 '19 at 03:24

2 Answers2

1

Using Regular Expression

import re

p = re.compile(r'(([\d\.-]+)(?::|\s)|(logged in))')

s = "2019.10.20-22.01.33: '10.11.111.25 9999995555884411:TechnoBeceT(69)' logged in"

q = [x[1] or x[2] for x in p.findall(s)]

print(q)

Output

['2019.10.20-22.01.33', '10.11.111.25', '9999995555884411', 'logged in']
DarrylG
  • 16,732
  • 2
  • 17
  • 23
0

Looks like you just need to split by ' ', ':' and 'TechnoBeceT(69)' as an appropriate regex. This existing question is probably what you need: Split string with multiple delimiters in Python

Joseph Boyd
  • 338
  • 2
  • 8