My regex:
vendor = "MyNameIsJoe. I'mWorkerInAAAinc."
ven = re.split(r'(?<=[a-z])[A-Z]|[A-Z](?=[a-z])', vendor)
To split strings by capital letter, for example:
'MyNameIsJoe. I'mWorkerInAAAinc' becomes 'My Name Is Joe. I'm Worker In AAA inc.'
You can use re.findall() in order to find the expected words rather than splitting:
In [46]: ' '.join(re.findall(r'[A-Z]?[^A-Z\s]+|[A-Z]+', vendor))
Out[46]: "My Name Is Joe. I'm Worker In AAA inc."
Note that this opting [A-Z]+ will match the AAA which means any combinations of uppercase letters with length <1 if you don't want this you can simple just use AAA.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With