* gry wrote: > I might want to replace '(max|min|cos|sqrt|ceil' with "public.\1", but > only with probability 0.7. I looked and looked for some computed > thing in re's that I could stick and expression, but could not find > such(for good reasons, I know). > Any ideas how to do this? I would go for simple, even if it's wildly > inefficient, though elegance is always admired...
You can run a re.sub() with a function as replacement value. This function then either returns the replacement or the original match based on a weighted random value. nd -- "Umfassendes Werk (auch fuer Umsteiger vom Apache 1.3)" -- aus einer Rezension <http://pub.perlig.de/books.html#apache2> -- http://mail.python.org/mailman/listinfo/python-list