[prev in list] [next in list] [prev in thread] [next in thread]
List: zope
Subject: Re: [Zope] Using RegEx in Script(Python)
From: Andreas Pakulat <ap125 () informatik ! uni-rostock ! de>
Date: 2003-06-30 23:54:49
[Download RAW message or body]
On 30.Jun 2003 - 19:21:07, Joel Burton wrote:
> On Fri, Jun 27, 2003 at 01:09:27AM +0200, Andreas Pakulat wrote:
> > Hi,
> >
> > 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.
> >
> > Andreas
>
> If you're looking to have a "clean-zope-id" method, we use the
> following. A simple regex solution can sometimes forget to fix things
> like leading underscores, or getting rid of double underscores or such.
> I actually do this w/o regexes using translate(), but regexs might be
> faster. Feel free to benchmark and say so. ;)
Thanks for that snippet. Looks really good, I'll give it a try, but I
don't think that I can benchmark it in the near future, as the site
won't go online so fast. Also the Strings I get are somewhat
well-formated, normally having only " " or "/" in it.
Andreas
--
Things will be bright in P.M. A cop will shine a light in your face.
_______________________________________________
Zope maillist - Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic