Quantcast
Channel: Python split string by multiple delimiters following a hierarchy - Stack Overflow
Browsing latest articles
Browse All 4 View Live

Answer by Ajax1234 for Python split string by multiple delimiters following a...

You can keep a list of the delimiters, ordered by their value. Then, you can combine re.split with re.findall to only use delimiters produced from the latter that are the least valuable in the split,...

View Article



Answer by Andrej Kesely for Python split string by multiple delimiters...

Try:import retests = [ ["121 34 adsfd", ["121 34 adsfd"]], ["dsfsd and adfd", ["dsfsd ", " adfd"]], ["dsfsd & adfd", ["dsfsd ", " adfd"]], ["dsfsd - adfd", ["dsfsd ", " adfd"]], ["dsfsd and adfd...

View Article

Answer by pho for Python split string by multiple delimiters following a...

This would be impractical with a single regular expression. You could get it to work with negative lookbehinds, but it would get quite complicated with each additional delimiter. It's pretty trivial to...

View Article

Python split string by multiple delimiters following a hierarchy

I want to split strings only once based on multiple delimiters like "and", "&" and "-" in that order. Example:'121 34 adsfd' -> ['121 34 adsfd']'dsfsd and adfd' -> ['dsfsd ', ' adfd']'dsfsd...

View Article
Browsing latest articles
Browse All 4 View Live




Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>