I am trying to understand re.split()
, I want to ignore comma separators, periods, and dashes.
What I am not understanding is why I get an empty string at the end of my result.
And I cannot seem to figure out how to ignore say a comma.
Here is my test code:
sntc = 'this is a sentence total $5678 fees: expenses $123,345 why not -2345 hey.'
test = re.split('\D*', sntc)
print(test)
I get the following output:
['', '5678', '123', '345', '2345', '']
Obviously, split picks up too much. I can deal with that by using a different Regex approach, but what I can’t figure out is why ''
is on either end of the result.