mirror of
https://github.com/kennethreitz/dive-into-python3.git
synced 2026-06-05 23:10:17 +00:00
coloring
This commit is contained in:
+7
-7
@@ -230,13 +230,13 @@ FAILED (errors=3)</samp></pre>
|
||||
<p class=d>[<a href=examples/roman9.py>download <code>roman9.py</code></a>]
|
||||
<pre class=pp><code>roman_numeral_pattern = re.compile('''
|
||||
^ # beginning of string
|
||||
<a> M{0,4} # thousands - 0 to 4 M's <span class=u>①</span></a>
|
||||
(CM|CD|D?C{0,3}) # hundreds - 900 (CM), 400 (CD), 0-300 (0 to 3 C's),
|
||||
# or 500-800 (D, followed by 0 to 3 C's)
|
||||
(XC|XL|L?X{0,3}) # tens - 90 (XC), 40 (XL), 0-30 (0 to 3 X's),
|
||||
# or 50-80 (L, followed by 0 to 3 X's)
|
||||
(IX|IV|V?I{0,3}) # ones - 9 (IX), 4 (IV), 0-3 (0 to 3 I's),
|
||||
# or 5-8 (V, followed by 0 to 3 I's)
|
||||
<a> M{0,4} # thousands - 0 to 4 Ms <span class=u>①</span></a>
|
||||
(CM|CD|D?C{0,3}) # hundreds - 900 (CM), 400 (CD), 0-300 (0 to 3 Cs),
|
||||
# or 500-800 (D, followed by 0 to 3 Cs)
|
||||
(XC|XL|L?X{0,3}) # tens - 90 (XC), 40 (XL), 0-30 (0 to 3 Xs),
|
||||
# or 50-80 (L, followed by 0 to 3 Xs)
|
||||
(IX|IV|V?I{0,3}) # ones - 9 (IX), 4 (IV), 0-3 (0 to 3 Is),
|
||||
# or 5-8 (V, followed by 0 to 3 Is)
|
||||
$ # end of string
|
||||
''', re.VERBOSE)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user