I am trying to capture the word following a cardinal number which is followed by a dot in a given text. For example, for the expression in quotation marks:
"1. text"
"text" should be returned. The "text" can be just plain letters or another number.
I have come up with the following regular expression which accomplishes exactly that:
r'(?:(?:(?<=\s)|(?<!.))\d+\.\s)([^\s.,:!?]*)'
The problem is that if "text" is of the same type as the non-capturing term, it is not checked again. Example:
"2. wordX wordY.": "wordX" is returned, expected behavior
"3. 4. wordZ.": "4" is returned, expected behavior.
I also expect to get "wordZ" as it matches in the expression "4. wordZ.", but it is not captured.
How do I get both where the matched expressions overlap?