I am stumped by this one. I am just learning regular expressions and cannot figure out why this will not return punctuation marks.
here is a piece of the text file the regex is parsing:
APRIL/NNP is/VBZ the/DT cruellest/JJ month/NN ,/, breeding/VBG Lilacs/NNP out/RB of/IN the/DT dead/JJ land/NN
text = open_file.read()grammarList = raw_input("Enter your grammar string: ");
tags = grammarList.split("^")tags_pattern = r'\s+'.join(r"([\w\,\:\;\"\-\.]+)/{0}".format(re.escape(tag)) for tag in tags) + r"\b"
print tags_patternfrom re import findall
start_position = 0for poem in poemList:start_position = text.find('<' + poem + '>', start_position)end_position = text.find('</' + poem + '>', start_position)searchtext = text [start_position:end_position]poemname = poemfor oldname, newname in poemtitleswapList.items():poemname = poemname.replace(oldname, newname)print (poemname)print (findall(tags_pattern, searchtext))print ("\n")
I thought that in the square brackets the "\," would allow it to return a "," but it is not working.
Any help would be appreciated.