#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2005
    Posts
    4
    Rep Power
    0

    Re.sub(...) problems


    For some reason my re.sub is not working. I know I have the syntax right though (via the Python reference), but the compiler complains about the syntax. I am just testing this with a simple html file with one line that has "<td id="pmaptbl"> ... </td>".

    Any help is greatly appreciated!

    r1 = re.compile('id.*pmaptbl')
    r2 = re.compile('<\/td>')
    r3 = re.compile('<td')
    r4 = re.compile('<.div>')
    r5 = re.compile('(.*?)<\/td>')
    r6 = re.compile('<.*?>')
    r7 = re.compile('(.*?)')
    r8 = re.compile('\n')

    [...]

    while 1:
    if tdFlag2 == 0:
    while 1:
    if (re.search(r2, mark) == None) and (tdFlag2 == 0):
    if re.search(r3, mark) or tdFlag:
    tdFlag = 1
    outp = outp + mark
    print outp
    i = i + 1
    mark = data[i]
    if re.search(r4, mark):
    tdFlag2 = 1
    else:
    break
    if tdFlag2 == 0:
    tdFlag = 0
    re.sub(r5, r7, mark)
    outp = outp + mark
    print outp
    i = i + 1
    mark = data1[i]
    else:
    break

    [...]
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2004
    Location
    There where the rabbits jump
    Posts
    556
    Rep Power
    11
    could you maybe post the error
    Those people who think they know everything are a great annoyance to those of us who do.
  4. #3
  5. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    Also, use code tags. It will make your code more easier to read and more noticeable.

IMN logo majestic logo threadwatch logo seochat tools logo