0

I have a string

a = bla bla bla bla

v = re.split("\[(.*?)\]@", a)

I get:

v =['bla', 'bla', 'bla', 'bla']

I want:

v =['bla', ' ', 'bla', ' ', 'bla', ' ', 'bla']

I found this as possible solution but dont know how to apply it:

return a[::2]

Any ideas? Thanks

Kazkuris
  • 39
  • 6
  • Always remember to google your question first, the link is first result to "python split strig keep separator" – azro Jan 09 '22 at 12:58
  • Also your input + regex DOES NOT give the output you show – azro Jan 09 '22 at 13:02

1 Answers1

0

I wonder why you need it, but it can be done like so

import re
a = 'bla bla bla bla'
temp = re.sub(' ','\t \t',a)
result = temp.split('\t')
bottledmind
  • 603
  • 3
  • 10