RegExp, Python and strings
Aahz Maruch
aahz at netcom.com
Sat Jan 8 10:12:54 EST 2000
More information about the Python-list mailing list
Sat Jan 8 10:12:54 EST 2000
- Previous message (by thread): RegExp, Python and strings
- Next message (by thread): RegExp, Python and strings
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In article <857hhb$3kmi$1 at www.univie.ac.at>, Matthias Huening <matthias.huening at univie.ac.at> wrote: > >In PERL I can do things like this (in one line): >$A = "Rossum, Guido van; Harms, Daryl; Python, Franz-Josef"; >$A =~ s/([A-Z])[\w]+(?![ \w\-]+,)([ ;-]|$)/$1.$2/g; >This RegExp results in: "Rossum, G. van; Harms, D.; Python, F.-J." > >Now I am trying to rebuild this in PYTHON, but I can't get it to work. >Any hints? Should I keep trying? Or should I stick to PERL for those >kinds of string-manipulations? You should be able to do that with re.sub(), but the syntax is slightly different. Don't forget to use raw strings, though (e.g. r'\w'). -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 The problem with an ever-changing .sig is that you have to keep changing it.
- Previous message (by thread): RegExp, Python and strings
- Next message (by thread): RegExp, Python and strings
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list