ich wollte mir ein Programm schreiben, das mir meine CSS Datei analysiert...
Bsp:
Code: Alles auswählen
body { color:red;}
div {color:blue;background-color:red;}
a {color:green;
font-weight:bold;}
span {color:yellow
float:left}
Code: Alles auswählen
#!/usr/bin/python
#-*- encoding: utf-8 -*-
import re
f = open('css.css','r')
all = f.read().replace('\t','').replace('\n','')
print all
print ''
print '-'*20
print ''
all = all.replace('}','}\n')
print all
print ''
print '-'*20
print ''
found = re.findall('[a-z][a-z0-9]([ ]|[])\{([a-z0-9\:\;\-\_\#].*)\}',all)
print found
Code: Alles auswählen
body { color:red;}div {color:blue;background-color:red;}a {color:green;font-weight:bold;}span {color:yellowfloat:left}
--------------------
body { color:red;}
div {color:blue;background-color:red;}
a {color:green;font-weight:bold;}
span {color:yellowfloat:left}
--------------------
['dy { color:red;', 'v {color:blue;background-color:red;', 'lor:green;font-weight:bold;', 'an {color:yellowfloat:left']
- Wieso werden die ersten 2 Buchstaben von den Tags abgeschnitten?
- Wieso wird die abschliesende Klammer } abgeschnitten?
- Gibt es irgendwo ein deutsche(s) Tutorial/Beschreibung für Python RegEx?