回答編集履歴
2
調整
test
CHANGED
@@ -5,3 +5,13 @@
|
|
5
5
|
$txt=preg_replace("/(?<=\.|。)(?=.)/misu","<br>",$txt);
|
6
6
|
print htmlspecialchars($txt);
|
7
7
|
```
|
8
|
+
|
9
|
+
# 調整版
|
10
|
+
```PHP
|
11
|
+
$txt=<<<eof
|
12
|
+
I don't know where to live. What do you say about that ?どこの住んだらいいんだろう。どう思う?Come to think of it, Mike said,"Once you live there, it's a heaven"Don't be so nervous.そういえばマイクは住めば都っていってたよ。そんなに神経質にならなくても。
|
13
|
+
eof;
|
14
|
+
$pattern='/(?<=[.?!])(?=[\x{30a0}-\x{30ff}\x{3040}-\x{309f}\x{3005}-\x{3006}\x{30e0}-\x{9fcf}])|(?<=[。!?])(?=[a-z])/misu';
|
15
|
+
$txt=preg_replace($pattern,"<br>",$txt);
|
16
|
+
print htmlspecialchars($txt);
|
17
|
+
```
|
1
調整
test
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
どこまで対応するのかわからないですが簡易的でよければこんな感じで
|
2
|
+
(最後に<br>をつけないように調整)
|
2
3
|
```PHP
|
3
4
|
$txt="It's my house.それは私の家です。Don't do it in my house.それをウチでやるな。y house is small.私の家は狭い。";
|
4
|
-
$txt=preg_replace("/(?<=\.|。)/misu","<br>",$txt);
|
5
|
+
$txt=preg_replace("/(?<=\.|。)(?=.)/misu","<br>",$txt);
|
5
6
|
print htmlspecialchars($txt);
|
6
7
|
```
|