If I have a string like this:
string = "12345|67891|23456|123456?"
how would I take out the "12345" and the "67891", etc (the characters between the pipes) and add them to a list all the way until the question mark (I am using the question mark in my code as a terminating character)?
A similar question has been asked here: How do I find the string between two special characters?
but I think mine is different because I need to do it multiple times in the same, one-line string.
Here is what I am hoping to achieve:
[PROGRAM BEGINS]
>>>string = "12345|67891|23456|123456?"
>>>string_list = []
>>>#some code to extract it and add it to a list called string_list
>>>print string_list
["12345","67891","23456","123456"]
[PROGRAM TERMINATES]
Thanks in advance!!
?should be included as well?