回答編集履歴
4
修正
answer
CHANGED
@@ -50,7 +50,7 @@
|
|
50
50
|
```PHP
|
51
51
|
$keyword="名詞,固有名詞,地域";
|
52
52
|
$a=array_map(function($x){
|
53
|
-
return preg_match("/^(.+)(?=
|
53
|
+
return preg_match("/^(.+?)(?=\s)/",$x,$match)?$match[1]:"";
|
54
54
|
},array_filter($output,function($x) use($keyword){
|
55
55
|
return preg_match("/".preg_quote($keyword,"/")."/",$x);
|
56
56
|
}));
|
3
調整
answer
CHANGED
@@ -50,7 +50,7 @@
|
|
50
50
|
```PHP
|
51
51
|
$keyword="名詞,固有名詞,地域";
|
52
52
|
$a=array_map(function($x){
|
53
|
-
return preg_match("/^(.+)(?=
|
53
|
+
return preg_match("/^(.+)(?=".chr(92)."s)/",$x,$match)?$match[1]:"";
|
54
54
|
},array_filter($output,function($x) use($keyword){
|
55
55
|
return preg_match("/".preg_quote($keyword,"/")."/",$x);
|
56
56
|
}));
|
2
調整
answer
CHANGED
@@ -41,11 +41,17 @@
|
|
41
41
|
```
|
42
42
|
|
43
43
|
# 修正
|
44
|
-
とりだしたあと、先頭の文字だけ抜き出す
|
44
|
+
- とりだしたあと、先頭の文字だけ抜き出す
|
45
|
+
- キーワードは工夫が必要
|
46
|
+
- $outputという変数を受けて処理する
|
47
|
+
|
48
|
+
もろもろ調整しました
|
49
|
+
|
45
50
|
```PHP
|
51
|
+
$keyword="名詞,固有名詞,地域";
|
46
52
|
$a=array_map(function($x){
|
47
53
|
return preg_match("/^(.+)(?=\s)/",$x,$match)?$match[1]:"";
|
48
|
-
},array_filter($
|
54
|
+
},array_filter($output,function($x) use($keyword){
|
49
55
|
return preg_match("/".preg_quote($keyword,"/")."/",$x);
|
50
56
|
}));
|
51
57
|
print_r($a);
|
1
修正
answer
CHANGED
@@ -38,4 +38,15 @@
|
|
38
38
|
return preg_match("/".preg_quote($keyword,"/")."/",$x);
|
39
39
|
});
|
40
40
|
print_r($a);
|
41
|
+
```
|
42
|
+
|
43
|
+
# 修正
|
44
|
+
とりだしたあと、先頭の文字だけ抜き出す
|
45
|
+
```PHP
|
46
|
+
$a=array_map(function($x){
|
47
|
+
return preg_match("/^(.+)(?=\s)/",$x,$match)?$match[1]:"";
|
48
|
+
},array_filter($a,function($x) use($keyword){
|
49
|
+
return preg_match("/".preg_quote($keyword,"/")."/",$x);
|
50
|
+
}));
|
51
|
+
print_r($a);
|
41
52
|
```
|