pat = "INT OF TWY (.*) AND TWY (.*) CLSD" all = re.search(pat, context, re.DOTALL) part1 = all.group(1) part2 = all.group(2) pat = "(.*), TWY (.*)" section = re.search(pat, all.group(1), re.DOTALL) if section != None: # print section.group(1) # print section.group(2) part1 = section.group(1) cross = part1 + "_" + part2 print "^ " + cross intersectionCLSD(cross, linestyle=linestyle) if __name__ == '__main__': if checkNOTAM() or checkFirstPost(): print checkNOTAM() print checkFirstPost() today = getday() traverseNOTAM() savePNG(today) if len(sys.argv) == 1: FB.post_graph(today, "") else: print "No NOTAM"