Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 317fc05

Browse files
author
Mark Pilgrim
committed
spacing fiddling
1 parent 1017051 commit 317fc05

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

regular-expressions.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,9 @@ <h2 id=phonenumbers>Case study: Parsing Phone Numbers</h2>
384384
<a><samp class=p>>>> </samp><kbd class=pp>phonePattern = re.compile(r'(\d{3})\D*(\d{3})\D*(\d{4})\D*(\d*)$')</kbd> <span class=u>&#x2460;</span></a>
385385
<a><samp class=p>>>> </samp><kbd class=pp>phonePattern.search('work 1-(800) 555.1212 #1234').groups()</kbd> <span class=u>&#x2461;</span></a>
386386
<samp class=pp>('800', '555', '1212', '1234')</samp>
387-
<a><samp class=p>>>> </samp><kbd class=pp>phonePattern.search('800-555-1212').groups()</kbd> <span class=u>&#x2462;</span></a>
387+
<a><samp class=p>>>> </samp><kbd class=pp>phonePattern.search('800-555-1212').groups()</kbd> <span class=u>&#x2462;</span></a>
388388
<samp class=pp>('800', '555', '1212', '')</samp>
389-
<a><samp class=p>>>> </samp><kbd class=pp>phonePattern.search('80055512121234').groups()</kbd> <span class=u>&#x2463;</span></a>
389+
<a><samp class=p>>>> </samp><kbd class=pp>phonePattern.search('80055512121234').groups()</kbd> <span class=u>&#x2463;</span></a>
390390
<samp class=pp>('800', '555', '1212', '1234')</samp></pre>
391391
<ol>
392392
<li>Note the lack of <code>^</code> in this regular expression. You are not matching the beginning of the string anymore. There&#8217;s nothing that says you need to match the entire input with your regular expression. The regular expression engine will do the hard work of figuring out where the input string starts to match, and go from there.

0 commit comments

Comments
 (0)