Returns the leading numeric part of a string. >>> numeric_part("20-alpha") 20 >>> numeric_part("foo") >>> numeric_part("16b") 16
(s)
| 33 | |
| 34 | |
| 35 | def numeric_part(s): |
| 36 | """Returns the leading numeric part of a string. |
| 37 | |
| 38 | >>> numeric_part("20-alpha") |
| 39 | 20 |
| 40 | >>> numeric_part("foo") |
| 41 | >>> numeric_part("16b") |
| 42 | 16 |
| 43 | """ |
| 44 | |
| 45 | m = re_numeric_part.match(s) |
| 46 | if m: |
| 47 | return int(m.group(1)) |
| 48 | return None |
| 49 | |
| 50 | |
| 51 | class Connection(_mysql.connection): |
no outgoing calls
no test coverage detected
searching dependent graphs…