Python Regex, Get Actual Line Back -


i trying regex on entire file, keep ending list this:

none none none none <_sre.sre_match object @ 0x7f89b0152db0> none <_sre.sre_match object @ 0x7f89b0152db0> 

how actual line back?

here code:

 dictionaryfile = "file.txt"  patternmatch = re.compile('^(\w{6,8})(\s+)(\d+)(\s+)(.+)(\s+)(\d{1,3}\s*-\s*\d{1,3})')   open(dictionaryfile) file:      line in file:           result = patternmatch.search(line)           print result 

here example of file regex'ing over:

hetelavl        2       there telephone elsewhere on           35 - 36                 people in household can                  contacted?                  edited universe:    hetelhhd = 2                  valid entries                  1   yes                 2   no   hephoneo       2       telephone interview acceptable?            37 - 38                  edited universe:    hetelhhd = 1 or hetelavl = 1                  valid entries                 1   yes                 2   no 

i back:

hetelavl        2       there telephone elsewhere on           35 - 36 hephoneo        2       telephone interview acceptable?            37 - 38 

search() returns none if no position in string matches pattern.

check if result not none , print line:

result = patternmatch.search(line) if result not none:     print line 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -