Message155100
| Author |
Phillip.M.Feldman |
| Recipients |
Phillip.M.Feldman, ezio.melotti, mrabarnett |
| Date |
2012年03月07日.17:28:33 |
| SpamBayes Score |
0.019743709 |
| Marked as misclassified |
No |
| Message-id |
<1331141314.19.0.206090274406.issue14221@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
The first example below works; the second one produces output containing garbage characters. (This came up while I was creating a set of examples for a tutorial on regular expressions).
import re
text= "The cat ate the rat."
print("before: %s" % text)
m= re.search("The (\w+) ate the (\w+)", text)
text= "The %s ate the %s." % (m.group(2), m.group(1))
print("after : %s" % text)
text= "The cat ate the rat."
print("before: %s" % text)
text= re.sub("(\w+) ate the (\w+)", "2円 ate the 1円", text)
print("after : %s" % text) |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2012年03月07日 17:28:34 | Phillip.M.Feldman | set | recipients:
+ Phillip.M.Feldman, ezio.melotti, mrabarnett |
| 2012年03月07日 17:28:34 | Phillip.M.Feldman | set | messageid: <1331141314.19.0.206090274406.issue14221@psf.upfronthosting.co.za> |
| 2012年03月07日 17:28:33 | Phillip.M.Feldman | link | issue14221 messages |
| 2012年03月07日 17:28:33 | Phillip.M.Feldman | create |
|