I\'m trying to extract the number before character \"M\" in a series of strings. The strings may look like:
\"107S33M15H\" \"33M100S\" \"12M100H33M\"
You can use rpartition to achieve that job.
s = '107S33M15H' prefix = s.rpartition('M')[0]