Python 3.3.2 - Using Regex to 'Clean Up' a List of Names
I am using Regex to clean up a list of names so that they are normal.
Let's say this list was...
000000AAAAAARob Alsod ## Notice multiple 0's and A's?
AAAPerson Person ## Here, too
Jeff the awesome Guy ## Four words...
Jenna DEeath ## A name like this can exist.
GEOFFERY EVERDEEN ## All caps
shy guy ## All lowercase
Theone Normalperson ## Example name. This one is fine.
Guywith Whitespace ## Trailing or leading whitespace is a nono.
So, as you can see, people don't format their names correctly, so I need a
program to highlight all the unwanted stuff. This includes:
Numbers at the start of the name.
Any uppercase without lowercase after. i.e. AAAAAAAJosh
Anything that is all uppercase.
Anything that doesn't start with uppercase. i.e. josh
Trailing and leading whitespace.
I think that is all I need to filter out. The ending product should look
something like this:
Rob Alsod ## No more 0's and A's.
Person Person ## No more leading A's (or other letters).
Jeff Guy ## No lowercase words in his name.
Jenna DEeath ## HASN'T removed the D in the middle.
## Name removed as it was all uppercase.
## Name removed as it was all lowercase.
Theone Normalperson ## Nothing changed.
Guywith Whitespace ## Removed whitespace.
Help is greatly appreciated.
No comments:
Post a Comment