回答編集履歴
2
訂正
test
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
|
17
17
|
b="XXX"
|
18
18
|
|
19
|
-
result = re.sub(f'((?:{re.escape(b)}.*?){{{n-1}}}){re.escape(b)}',f'\1{
|
19
|
+
result = re.sub(f'((?:{re.escape(b)}.*?){{{n-1}}}){re.escape(b)}',f'\1{a}',sample)
|
20
20
|
|
21
21
|
```
|
22
22
|
|
1
追記
test
CHANGED
@@ -7,3 +7,17 @@
|
|
7
7
|
result = re.sub(f'((?:XXX.*?){{{n-1}}})XXX',r'\1xxx',sample)
|
8
8
|
|
9
9
|
```
|
10
|
+
|
11
|
+
```Python
|
12
|
+
|
13
|
+
n=2
|
14
|
+
|
15
|
+
a="xxx"
|
16
|
+
|
17
|
+
b="XXX"
|
18
|
+
|
19
|
+
result = re.sub(f'((?:{re.escape(b)}.*?){{{n-1}}}){re.escape(b)}',f'\1{re.escape(a)}',sample)
|
20
|
+
|
21
|
+
```
|
22
|
+
|
23
|
+
長い、、、か。
|