回答編集履歴

2

追記

2018/09/12 07:54

投稿

LouiS0616
LouiS0616

スコア35660

test CHANGED
@@ -49,3 +49,7 @@
49
49
  10点一致しました({0}、{1}、{2}、{3}、{4}、{5}、{6}、{7}、{8}、{9})
50
50
 
51
51
  ```
52
+
53
+
54
+
55
+ [Matcher#replaceAll​(Function<MatchResult,String>)](https://docs.oracle.com/javase/jp/10/docs/api/java/util/regex/Matcher.html#replaceAll(java.util.function.Function))

1

修正

2018/09/12 07:54

投稿

LouiS0616
LouiS0616

スコア35660

test CHANGED
@@ -14,27 +14,21 @@
14
14
 
15
15
 
16
16
 
17
- Matcher matcher = Pattern.compile("%(\d+)")
17
+ String dst = Pattern.compile("%(\d+)")
18
18
 
19
19
  .matcher(src)
20
20
 
21
- ;
21
+ .replaceAll(
22
22
 
23
-
24
-
25
- String dst = matcher.replaceAll(
26
-
27
- m -> {
28
-
29
- return String.format(
23
+ m -> String.format(
30
24
 
31
25
  "{%d}", Integer.valueOf(m.group(1)) - 1
32
26
 
33
- );
27
+ )
34
28
 
35
- }
29
+ )
36
30
 
37
- );
31
+ ;
38
32
 
39
33
 
40
34
 
@@ -48,7 +42,7 @@
48
42
 
49
43
 
50
44
 
51
- **実行結果** [Wandbox](https://wandbox.org/permlink/YkXZXt89Oz0XBg3B)
45
+ **実行結果** [Wandbox](https://wandbox.org/permlink/KEqLBZidcOWJYq5v)
52
46
 
53
47
  ```plain
54
48