Re: spaces from a web form
Clodoaldo Pinto Neto <[email protected]> Thu, 23 Jul 2009 10:32:17 -0300
| Newsgroups | gmane.comp.python.mod_python |
|---|---|
| Message-ID | <[email protected]> |
2009/7/23 Rakotomandimby Mihamina <[email protected]>: > Hi all > let the following simplified code be: > > import re > textarea=for.getfirst('text') > spaces=re.compile('^( )+$') > new_txt=re.sub(spaces, '_', textarea) > > The HTML is a very simple form with a textarea. > The substitution doesnt occur. The '+' signs > in the Url seem to be stripped and replaced by > something not matched as a space; What does this code shows?: [ord(x) for x in unicode(textarea, 'utf8')] Replace utf8 for whatever is the used encoding. The best aproach is to just strip leading and trailing spaces: new_txt = textarea.lstrip(' ').rstrip(' ') Regards, Clodoaldo > > I already tried with something like "\s" in the regexp > but no more luck. Any more tips? > Thank you. > > -- > Architecte Informatique: > Administration Systeme, Recherche & Developpement > + 261 32 11 401 65 > Pensez a l'environnement avant d'imprimer ce message > _______________________________________________ > Mod_python mailing list > [email protected] > http://mailman.modpython.org/mailman/listinfo/mod_python >