Hey everyone! Thanks for all the responses, they were all very helpful. It turns out that I solved this one shortly after posting (that always happens to me!) and I did use a regular expression, mostly the same as my first one (it turns out that the + flag on the first [A-Z] was unnecessary for my purposes):
Code:
import re
regword = re.compile("[A-Z](\S*[A-Z]+)*", re.I)
Hello everyone, I'm new to Python and also new to this forum and I have a question regarding regular expressions, so here goes:
I am attempting to read in a text and do some pattern matching before I store words in a dictionary. I basically want to read in the words and remove any numbers, punctuation, or other special characters from the beginning and end of the word. However, I do wish to keep all of the above in the word if the...
Leave a comment: