CR LF
Jonadab the Unsightly One
jonadab at bright.net
Tue Sep 5 07:16:19 EDT 2000
More information about the Python-list mailing list
Tue Sep 5 07:16:19 EDT 2000
- Previous message (by thread): Windows runtime
- Next message (by thread): CR LF
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Alex Martelli" <alex at magenta.com> wrote: > ...except that if your text includes less-than signs, etc etc, disaster > looms. > > You also need to change < to <, etc, etc (not sure if some standard > Python > library module already has that functionality...?). A series of regular-expression replaces seems to be in order. I don't (yet!) know Python, but in elisp or Perl this would be pretty trivial, so I expect Python should be able to do it also. Something like this elisp... (replace-string "&" "&") (replace-string "<" "<") (replace-string ">" ">") (replace-string "\"" """) (replace-regexp "^" "<div>") (replace-regexp "$" "</div>") Or, in Perl, ... s/\&/&/; s/</</; s/>/>/; s/\"/"/; s/^/<div>/; s/$/<\/div>/; Heck, I could do that in under 20 lines of line number BASIC; it can't be hard in Python, can it? Okay, if strings are immutable then your replace-substring function will have to fake it by making a new string using concatenation, but still... it sounds easy to me. - jonadab
- Previous message (by thread): Windows runtime
- Next message (by thread): CR LF
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list