[Zope] How to check if a string contains some characters??

Marcello Lupo lupo@icmnet.net
Tue, 13 Mar 2001 11:09:09 +0100


Thank you very much.
Placed in an external method works great.
Bye,
MArcello


Dennis Nichols wrote:
> 
> At 3/12/01 04:39 PM, Tino Wildenhain wrote:
> >in pure python you can also write:
> ># -------------------------------------------------
> >import re
> >
> >if re.search(r"[^A-Za-z0-9\.\-_]",string_name):
> >         raise Exception("illegal character here.")
> >
> ># -------------------------------------------------
> >
> >However this is untested. But you get the idea ;)
> >re is certainly faster then in-loops.
> 
> I didn't test it either, but note that "." is not a special character
> inside the [] pair and that a bare "-" as the first or last character
> stands for itself. So the string could be more clearly written (imho) as just:
> 
>      [^A-Za-z0-9._-]
> 
> --
> Dennis Nichols
> nichols@tradingconnections.com

-- 
----------------------------------------
Marcello Lupo            Project Manager
               Atis Srl
          Via dell'Artigliere 2
      37014 Castelnuovo del Garda (VR)
Tel. +39-0457570960 - Fax +39-0457571268
       E-mail: lupo@atisworld.com
        http://www.atisworld.com
-----------------------------------------