1
messense 2014-07-21 19:22:43 +08:00
>>> s = """AC1DE2FB
... AC3DE4FB ... AC5DE6FB""" >>> import re >>> s 'AC1DE2FB\nAC3DE4FB\nAC5DE6FB' >>> pattern = re.compile(r'\w+?(\d+?)\w+?(\d+?)\w*', re.S | re.M) >>> dir(pattern) ['__copy__', '__deepcopy__', 'findall', 'finditer', 'match', 'scanner', 'search', 'split', 'sub', 'subn'] >>> pattern.findall(s) [('1', '2'), ('3', '4'), ('5', '6')] |
2
messense 2014-07-21 19:25:07 +08:00 1
以上是终端下试的,完整代码:
import re pattern = re.compile(r'\w+?(\d+?)\w+?(\d+?)\w*', re.S | re.M) s = """AC1DE2FB AC3DE4FB AC5DE6FB""" result = pattern.findall(s) 然后可以再对 result 做进一步处理。 |
3
lapertem4 OP |
6
lapertem4 OP test post data
|