回答編集履歴

1

chousei

2019/09/03 00:48

投稿

yambejp
yambejp

スコア114883

test CHANGED
@@ -8,12 +8,34 @@
8
8
 
9
9
  foreach($array as $str){
10
10
 
11
- if(preg_match($pattern,$str,$m)){
11
+ if(preg_match($pattern,$str)){
12
12
 
13
- print_r($m);
13
+ print $str."<br>";
14
14
 
15
15
  }
16
16
 
17
17
  }
18
18
 
19
19
  ```
20
+
21
+ まぁいちいち組み合わせを考えるよりはand検索すればよいような気がします
22
+
23
+ ```PHP
24
+
25
+ $array=["a1","aa","1a","11","a_1","a_a","1_a","1_1","B1","BB","1B","B_1","B_B","1_B"];
26
+
27
+ $pattern1="/[a-z]/i";
28
+
29
+ $pattern2="/\d/";
30
+
31
+ foreach($array as $str){
32
+
33
+ if(preg_match($pattern1,$str) and preg_match($pattern2,$str)){
34
+
35
+ print $str."<br>";
36
+
37
+ }
38
+
39
+ }
40
+
41
+ ```