View Single Post
Old 04-08-2009, 11:01 AM   #10
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,382
Karma: 27756918
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You dont have to use a lambda function you can use a normal function as well


For example

Code:
def my_function(match):
   length_of_backrefs = len(''.join([match.group(i) for i in range(1, 4)]))
   full_string = match.group()
   # do something to full string
   return substituted_string
And in the regexp list

(re.compile(r'(.*)<br.*?>', re.IGNORECASE), my_function),
kovidgoyal is offline   Reply With Quote