I have a long string separated with ordinal numbers. For example: “1. Good morning 2. Hello 3. Bye” (but it is not compulsory that there is a number at beginning and I don’t knew how many numbers are there, if any.) and I would like to get list like this: ["Good morning", "Hello", "Bye"]
I have a long string separated with ordinal numbers. For example: 1. Good morning
Share
If there’s no number in the beginning, the first element will not be empty. However, this doesn’t check that the numbers are in correct order. Let me know if this is important.
Edit: thanks to @glglgl for the comment. Splitting on
' *\d+\. *'may be better in terms of leading/trailing spaces.