说我有这些字符串:
1. TOP FLAT
2. FLAT 7
3. FLAT B
4. GROUND FLOOR FLAT
5. STUDIO 1.02
6. APARTMENT 10
7. GROUND AND FIRST FLOOR MAISONETTE
8. FLAT A
正则表达式会给我什么:
1. TOP
2. 7
3. B
4. GROUND FLOOR
5. 1.02
6. 10
7. Ground and first floor
8. A
区分大小写并不重要。在过去的几个小时里,我一直在反对这一点,但我似乎无处可去。
感谢您的帮助!
答案 0 :(得分:0)
(这是perl,但RE工作)
while ( <DATA> ) {
s/(house|maisonette|studio|apartment|flat) ?//gi;
print;
}
__DATA__
1. TOP FLAT
2. FLAT 7
3. FLAT B
4. GROUND FLOOR FLAT
5. STUDIO 1.02
6. APARTMENT 10
7. GROUND AND FIRST FLOOR MAISONETTE
8. FLAT A
给出:
1. TOP
2. 7
3. B
4. GROUND FLOOR
5. 1.02
6. 10
7. GROUND AND FIRST FLOOR
8. A
答案 1 :(得分:0)