Results 1 to 2 of 2

Thread: [RESOLVED] Regex in python

  1. #1

    Thread Starter
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

    Resolved [RESOLVED] Regex in python

    Hi guys good day. First time to touch Python and i'm stuck in regex. Honestly speaking i'm no good in regex, so I need help about this one.

    so far this is my code.
    Code:
    import re
    micro_list = open('c:/my documents/my sample project/mhtbuilder_demo/bin/msdnlibrary.mht','r+b')
    
    m = re.search('(?<=[<table class=3D"data">])\w+',micro_list)
    if m:        
       print m.group(0)
    I want to get on what's between <table class=3D"data"> </table>. so far the pattern lacks </table> so basically I just get data after <table class=3D"data"> pattern because I don't on how to deal that one.

    thanx in advance guys.
    Last edited by mar_zim; Oct 6th, 2006 at 12:53 AM.

  2. #2

    Thread Starter
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

    Re: Regex in python

    Never mind I got it.
    Code:
    import re
    samlist =  open('sampletxt.txt','r+b')
    m =  samlist.read()
    p = re.search('<table class=3D"data">(.*)</TABLE>',m,re.DOTALL)
    if p:
        print p.group(0)
    else:
        print 'no match'
    
    samlist.close()

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width