回答編集履歴
3
追記
answer
CHANGED
@@ -20,4 +20,27 @@
|
|
20
20
|
> 半角空白のみ)が含まれたタグ
|
21
21
|
|
22
22
|
というのは「<p> </p>」を指すのか、「<p>a b</p>」もそうなのか
|
23
|
-
どういう状況でしょうか?
|
23
|
+
どういう状況でしょうか?
|
24
|
+
|
25
|
+
# 追記
|
26
|
+
|
27
|
+
```PHP
|
28
|
+
<?PHP
|
29
|
+
$content=<<<eof
|
30
|
+
a<p> </p>b
|
31
|
+
c<p> </p>d
|
32
|
+
e<p> \t</p>f
|
33
|
+
g<p>
|
34
|
+
\t</p>h
|
35
|
+
eof;
|
36
|
+
|
37
|
+
print preg_replace('/<p>\x20</p>/is','', $content);
|
38
|
+
print "\n<hr>\n";
|
39
|
+
print preg_replace('/<p>\x20+</p>/is','', $content);
|
40
|
+
print "\n<hr>\n";
|
41
|
+
print preg_replace('/<p>\s+</p>/is','', $content);
|
42
|
+
|
43
|
+
```
|
44
|
+
|
45
|
+
半角スペースは「\x20」でマッチさせると見やすいです。
|
46
|
+
「\s」をつかうと\tや\nにもマッチします
|
2
追記
answer
CHANGED
@@ -6,8 +6,8 @@
|
|
6
6
|
klm</p>
|
7
7
|
nop
|
8
8
|
eof;
|
9
|
-
|
10
|
-
$
|
9
|
+
$pattern='/<p>.*?</p>/is';
|
10
|
+
$content=preg_replace($pattern,'', $content);
|
11
11
|
print $content;
|
12
12
|
```
|
13
13
|
|
@@ -15,4 +15,9 @@
|
|
15
15
|
|
16
16
|
```
|
17
17
|
$pattern="/<p>\x20</p>/";
|
18
|
-
```
|
18
|
+
```
|
19
|
+
|
20
|
+
> 半角空白のみ)が含まれたタグ
|
21
|
+
|
22
|
+
というのは「<p> </p>」を指すのか、「<p>a b</p>」もそうなのか
|
23
|
+
どういう状況でしょうか?
|
1
追記
answer
CHANGED
@@ -9,4 +9,10 @@
|
|
9
9
|
|
10
10
|
$content=preg_replace('/<p>.*?</p>/is','', $content);
|
11
11
|
print $content;
|
12
|
+
```
|
13
|
+
|
14
|
+
すみません、半角スペース一つという条件でした
|
15
|
+
|
16
|
+
```
|
17
|
+
$pattern="/<p>\x20</p>/";
|
12
18
|
```
|