[Zope] Using RegEx in Script(Python)

Steffen Hausmann steffen@hausmann-family.de
Fri, 27 Jun 2003 01:53:27 +0200


On Fri, Jun 27, 2003 at 01:09:27AM +0200, Andreas Pakulat wrote:
> I wanted to know if the above can be done? What I need is a function
> that replaces every character of a string, that is not in [a-zA-Z1-9]
> with an underscore. I want to use this to automatically create an
> Object-Id from a title, to create a new Object.
> 
> If this is not possible directly within a Script(Python), can it be done
> using an ExternalMethod? I suppose yes.

In order to use regular expressions in python you need to 'import re'.

After that you can use 'sub(pattern, repl, string[, count])' to
substitue a string.

For more information on regexps in python take a look at
http://www.python.org/doc/current/lib/node99.html#l2h-732

MfG Steffen
-- 
Zu sagen 'Hier herrscht Freiheit' ist immer ein Irrtum oder auch eine
Lüge -- Freiheit herrscht nicht (Erich Fried)