回答編集履歴
3
edit
answer
CHANGED
@@ -6,6 +6,6 @@
|
|
6
6
|
import re
|
7
7
|
a = 'aaa, bbb[12, 13, 14]. ccc.'
|
8
8
|
nums = re.findall('[\d][\d]*', a)
|
9
|
-
h, e = re.split('[
|
9
|
+
h, e = re.split('[[\d\D]*]', a)
|
10
10
|
s = '{0}{1}{2}'.format(h, ' '.join(map('[{0}]'.format, nums)), e)
|
11
11
|
```
|
2
edit
answer
CHANGED
@@ -8,6 +8,4 @@
|
|
8
8
|
nums = re.findall('[\d][\d]*', a)
|
9
9
|
h, e = re.split('[|]', a)[::2]
|
10
10
|
s = '{0}{1}{2}'.format(h, ' '.join(map('[{0}]'.format, nums)), e)
|
11
|
-
print(a)
|
12
|
-
print(s)
|
13
11
|
```
|
1
edit
answer
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
```python
|
6
6
|
import re
|
7
7
|
a = 'aaa, bbb[12, 13, 14]. ccc.'
|
8
|
-
nums =
|
8
|
+
nums = re.findall('[\d][\d]*', a)
|
9
9
|
h, e = re.split('[|]', a)[::2]
|
10
10
|
s = '{0}{1}{2}'.format(h, ' '.join(map('[{0}]'.format, nums)), e)
|
11
11
|
print(a)
|