Bonjour tout le monde!

On m'a filé un code pour m'en inspirer... a priori, ça parle d'expressions régulières mais je ne le comprends pas! Quelqu'un pourrait-il me l'expliquer ou me le commenter, please?

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 
import re
some_string='-</th></tr> <tr><th>12  -</th></tr> <tr horiz="no" hight=45><th>34 '
re_buildnr=re.compile(r'-</th></tr> <tr[ 0-9a-zA-Z="]*><th>(?P<buildnr>\d+)')
match_buildnr=re_buildnr.search(some_string)
print type(match_buildnr)
if match_buildnr == None:
	log.p('Error:   Due to change in URL format, no build information was retrieved from URL: %s' % (url))
	sys.ex(1)
 
while match_buildnr != None:
	startpos=match_buildnr.start()+1
	newest_buildnr=match_buildnr.group('buildnr')
	newest_buildnr=int(newest_buildnr)
	print "100*nr is %i" % (newest_buildnr*100)
	match_buildnr=re_buildnr.search(some_string, startpos)
Sinon, ce code est fait pour m'aider à parcourir un string pour retrouver dedans tous les "resultats" de mon expression régulière.

Merci

deedoo...