程序填空题:python正则表达式-规律
找出下列数据的规律,然后进行匹配。。
需要匹配的
* abc01
* ddd02
* afcf01
* acac11
* 321
* acef33
* bbc000
不能匹配的
* ABCDEFG789654
* CODEJIAONANG
* ghjkloiqwtq
* poiuy98765
* msstgr4567
* gg8888888
* 88888888999
```python
import re
contents='''
abc01
ddd02
afcf01
acac11
321
acef33
bbc000
ABCDEFG789654
CODEJIAONANG
ghjkloiqwtq
poiuy98765
msstgr4567
gg8888888
88888888999
'''
p = re.compile(r'')
for line in p.findall(contents):
print(line)
```
答案:
第1空:[a-f0-3]+
需要匹配的
* abc01
* ddd02
* afcf01
* acac11
* 321
* acef33
* bbc000
不能匹配的
* ABCDEFG789654
* CODEJIAONANG
* ghjkloiqwtq
* poiuy98765
* msstgr4567
* gg8888888
* 88888888999
```python
import re
contents='''
abc01
ddd02
afcf01
acac11
321
acef33
bbc000
ABCDEFG789654
CODEJIAONANG
ghjkloiqwtq
poiuy98765
msstgr4567
gg8888888
88888888999
'''
p = re.compile(r'')
for line in p.findall(contents):
print(line)
```
答案:
第1空:[a-f0-3]+