python - Extract Parts of String from in Between Two Characters -


if have string this:

string = "12345|67891|23456|123456?" 

how take out "12345" , "67891", etc (the characters between pipes) , add them list way until question mark (i using question mark in code terminating character)?

a similar question has been asked here: how find string between 2 special characters?

but think mine different because need multiple times in same, one-line string.

here hoping achieve:

[program begins] >>>string = "12345|67891|23456|123456?" >>>string_list = [] >>>#some code extract , add list called string_list >>>print string_list ["12345","67891","23456","123456"] [program terminates] 

thanks in advance!!

you don't need use question mark:

>>> string = "12345|67891|23456|123456" >>> string.split('|') ['12345', '67891', '23456', '123456'] >>> 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -