回答編集履歴
1
追記
answer
CHANGED
@@ -18,4 +18,27 @@
|
|
18
18
|
preg_match($p2,$str,$matches[1]);
|
19
19
|
preg_match($p3,$str,$matches[2]);
|
20
20
|
print $str.":".(count(array_filter($matches,function($x){return count($x)>0;}))>=2?"OK":"NG")."<br>";
|
21
|
+
```
|
22
|
+
|
23
|
+
|
24
|
+
# 追記
|
25
|
+
こっちのほうがまともなアプローチかもしれません
|
26
|
+
```PHP
|
27
|
+
function check($str){
|
28
|
+
$pattern="/([abc])|([ABC])|([123])/";
|
29
|
+
preg_match_all($pattern,$str,$matches);
|
30
|
+
array_shift($matches);
|
31
|
+
return count(array_filter($matches,function($x){
|
32
|
+
return count(array_filter($x,function($y){
|
33
|
+
return $y!=="";
|
34
|
+
}))>0;
|
35
|
+
}));
|
36
|
+
}
|
37
|
+
print check("xyz");
|
38
|
+
print check("abcx");
|
39
|
+
print check("a3x");
|
40
|
+
print check("abc123xyz");
|
41
|
+
print check("aB3");
|
42
|
+
print check("abcABC123xyz");
|
43
|
+
|
21
44
|
```
|