回答編集履歴
1
追記
test
CHANGED
@@ -39,3 +39,49 @@
|
|
39
39
|
print $str.":".(count(array_filter($matches,function($x){return count($x)>0;}))>=2?"OK":"NG")."<br>";
|
40
40
|
|
41
41
|
```
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
# 追記
|
48
|
+
|
49
|
+
こっちのほうがまともなアプローチかもしれません
|
50
|
+
|
51
|
+
```PHP
|
52
|
+
|
53
|
+
function check($str){
|
54
|
+
|
55
|
+
$pattern="/([abc])|([ABC])|([123])/";
|
56
|
+
|
57
|
+
preg_match_all($pattern,$str,$matches);
|
58
|
+
|
59
|
+
array_shift($matches);
|
60
|
+
|
61
|
+
return count(array_filter($matches,function($x){
|
62
|
+
|
63
|
+
return count(array_filter($x,function($y){
|
64
|
+
|
65
|
+
return $y!=="";
|
66
|
+
|
67
|
+
}))>0;
|
68
|
+
|
69
|
+
}));
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
print check("xyz");
|
74
|
+
|
75
|
+
print check("abcx");
|
76
|
+
|
77
|
+
print check("a3x");
|
78
|
+
|
79
|
+
print check("abc123xyz");
|
80
|
+
|
81
|
+
print check("aB3");
|
82
|
+
|
83
|
+
print check("abcABC123xyz");
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
```
|