how to match this text?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sidooh
    New Member
    • Dec 2009
    • 9

    how to match this text?

    Hi,everyone!

    I want to match <tr>...</tr> in my text file(exp.txt).

    this is my python source code:
    Code:
    import re
    
    f = open("exp.txt","r")
    str = f.read()
    
    pat = re.compile("<tr>.*</tr>")
    m = pat.findall(str)
    print(m)
    but it didn't work,what should I do?
    Attached Files
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    Try this pattern:
    Code:
    tag = "tr"
    patt = re.compile('<%s>(.+?)</%s>' % (tag,tag), re.S|re.M)

    Comment

    • sidooh
      New Member
      • Dec 2009
      • 9

      #3
      Thank you very much!

      Sorry for my late reply

      Comment

      Working...