[Tutor] Regexp question

Ovidiu Bivolaru ovidiu.bivolaru@ravantivirus.com
Mon May 19 10:35:02 2003


--=-qYenDobwLOVqa9A6RZ1C
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

Hi all,

I'm trying to parse some HTML forms to get the values from "name" and
"value" attributes and then to add them in a list. I'm encountering a
problem with the regular expressions and I can't figure out why the
expression is invalid.

Bellow is the code that I'm using:
    for lines in buffer.readlines():
      print lines
      regexp =3D 'value=3D"(.*)?"\s*name\s*=3D\s*"(.*:\d+:\d+)?"'
      print regexp
      p =3D re.search(regexp,lines)

The error message is:
    p =3D re.search(regexp,lines)
  File "/usr/lib/python2.2/sre.py", line 137, in search
    return _compile(pattern, flags).search(string)
  File "/usr/lib/python2.2/sre.py", line 229, in _compile
    raise error, v # invalid expression
error: nothing to repeat

Can anybody tell me what is wrong with the regular expression?? Also,
are any other possibilities to parse the HTML using functions already
implemented  (i.e. HTMLPasrse module) ??


Thanks,
Ovidiu


--=-qYenDobwLOVqa9A6RZ1C
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQA+yOp3jQG4unFXu9sRAjVgAJ9E3QPIemKJXP6FCR1OdPjc/ELo5wCgpGYH
S8bYTcsu6mv6VQW+X3vekow=
=oeCQ
-----END PGP SIGNATURE-----

--=-qYenDobwLOVqa9A6RZ1C--