como fazer a largura e a altura x2 usando python Regular
Eu tenho que fazer muitos trabalhos para mudar assim:
<img src = "/" height="111" width="10" />
par
<img src = "/" height="222" width="20" />
então eu quero usar python Regular este é o meu código:
import re
s = '<img src = "werwerwe" height="111" width="10" />'
def a(x):
print x.group(2)
print x.group(4)
ss = re.sub(r'''<img.*(width\s*="?(\d+)"?)*\s*(height\s*="?(\d+)"?)*''',a, s)
print ss
então o que eu posso fazer
obrigad
Atualizada
esta bem agora
import re
s = '<img src = "/" height="111" width="10" />'
def a(x):
b = x.group(0)
b = b.replace(x.group(1),str(int(x.group(1))*2))
b = b.replace(x.group(2),str(int(x.group(2))*2))
return b
ss = re.sub(r'''<img.*?height=\"(\d+)\".*?width=\"(\d+)\"[^>]*>''',a, s)
print ss