Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion book3/11-regex.mkd
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ with the following regular expression.
~~~~ {.python}
import re
x = 'We just received $10.00 for cookies.'
y = re.findall('\$[0-9.]+',x)
y = re.findall(r'\$[0-9.]+',x)
~~~~

Since we prefix the dollar sign with a backslash, it actually matches
Expand Down
2 changes: 1 addition & 1 deletion book3/translation/book-tl/11-regex.mkd
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ gamit ang sumusunod na regular expression.
~~~~ {.python}
import re
x = 'We just received $10.00 for cookies.'
y = re.findall('\$[0-9.]+',x)
y = re.findall(r'\$[0-9.]+',x)
~~~~

Dahil nag-prefix tayo ng dollar sign ng backslash, aktwal na tumutugma ito sa
Expand Down
8 changes: 4 additions & 4 deletions code3/gmane/gmane.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,20 @@ def parsemaildate(md) :
continue

email = None
x = re.findall('\nFrom: .* <(\S+@\S+)>\n', hdr)
x = re.findall(r'\nFrom: .* <(\S+@\S+)>\n', hdr)
if len(x) == 1 :
email = x[0];
email = email.strip().lower()
email = email.replace("<","")
else:
x = re.findall('\nFrom: (\S+@\S+)\n', hdr)
x = re.findall(r'\nFrom: (\S+@\S+)\n', hdr)
if len(x) == 1 :
email = x[0];
email = email.strip().lower()
email = email.replace("<","")

date = None
y = re.findall('\Date: .*, (.*)\n', hdr)
y = re.findall(r'\Date: .*, (.*)\n', hdr)
if len(y) == 1 :
tdate = y[0]
tdate = tdate[:26]
Expand All @@ -174,7 +174,7 @@ def parsemaildate(md) :
continue

subject = None
z = re.findall('\Subject: (.*)\n', hdr)
z = re.findall(r'\Subject: (.*)\n', hdr)
if len(z) == 1 : subject = z[0].strip().lower();

# Reset the fail counter
Expand Down
4 changes: 2 additions & 2 deletions code3/gmane/gmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ def parsemaildate(md) :
def parseheader(hdr, allsenders=None):
if hdr is None or len(hdr) < 1 : return None
sender = None
x = re.findall('\nFrom: .* <(\S+@\S+)>\n', hdr)
x = re.findall(r'\nFrom: .* <(\S+@\S+)>\n', hdr)
if len(x) >= 1 :
sender = x[0]
else:
x = re.findall('\nFrom: (\S+@\S+)\n', hdr)
x = re.findall(r'\nFrom: (\S+@\S+)\n', hdr)
if len(x) >= 1 :
sender = x[0]

Expand Down
2 changes: 1 addition & 1 deletion code3/re14.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
hand = open('mbox-short.txt')
for line in hand:
line = line.rstrip()
x = re.findall('Author:.*@(\S+)', line)
x = re.findall(r'Author:.*@(\S+)', line)
if not x: continue
print(x)
2 changes: 1 addition & 1 deletion html3/11-regex.php
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ class="citation" data-cites="2PM">@2PM</span>” because there are no
with the following regular expression.</p>
<pre class="python"><code>import re
x = &#39;We just received $10.00 for cookies.&#39;
y = re.findall(&#39;\$[0-9.]+&#39;,x)</code></pre>
y = re.findall(r&#39;\$[0-9.]+&#39;,x)</code></pre>
<p>Since we prefix the dollar sign with a backslash, it actually matches
the dollar sign in the input string instead of matching the “end of
line”, and the rest of the regular expression matches one or more digits
Expand Down