I have the following string
u'root\n |-- date: string (nullable = true)\n |-- zip: string (nullable = true)\n'
I would like to extract the column names. The column names have |-- before them and : after them.
I could do this in two stages:
s = u'root\n |-- date: string (nullable = true)\n |-- zip: string (nullable = true)\n'
s = s.split('|-- ')
s = s.split(':')
However, I wanted to know if there is a way to split with two characters at once.
However, I wanted to know if there is a way to split with two characters at once.
It is possible using re#split:
re.split(r'\|--|:', your_string)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With