[python] regex deel moet voorkomen en een deel niet

Pagina: 1
Acties:

  • Boertje
  • Registratie: September 2001
  • Laatst online: 23-02 20:38
even een voorbeeld om het te verduidelijken:

Python:
1
2
string = '"GET /phpmyadmin/favicon.ico HTTP/1.1" 404 310'
print re.match('[^favicon]*.*404',string)


^uitkomst: <_sre.SRE_Match object at 0x009D9870>
wat ik dus niet wil (8>

van deze string wil ik matchen op 404, maar wanneer er favicon in voorkomt moet de regex niet matchen.

  • NMe
  • Registratie: Februari 2004
  • Laatst online: 22-01 23:51

NMe

Quia Ego Sic Dico.

Zoek eens uit wat character classes zijn, en waarom [^favicon] dan niet doet wat jij wil. ;)

'E's fighting in there!' he stuttered, grabbing the captain's arm.
'All by himself?' said the captain.
'No, with everyone!' shouted Nobby, hopping from one foot to the other.