回答編集履歴
3
誤字の修正
answer
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
$test = 'a\\b';
|
11
11
|
//この正規表現では、「\,:,?,<,>,|」と「./」と「../」を検索します。
|
12
12
|
//(あえてスラッシュは正規表現の検索対象としていません。)
|
13
|
-
$a = preg_match('#[\\\
|
13
|
+
$a = preg_match('#[\\\:?<>|]|\.{1,2}/#', $test,$m);
|
14
14
|
```
|
15
15
|
###追記
|
16
16
|
```php
|
2
正規表現による記述を追記
answer
CHANGED
@@ -5,6 +5,13 @@
|
|
5
5
|
return strlen($s) !== strlen(mb_convert_encoding(mb_convert_encoding($s,'SJIS','UTF-8'),'UTF-8','SJIS'));
|
6
6
|
}
|
7
7
|
```
|
8
|
+
###正規表現によるチェック
|
9
|
+
```php
|
10
|
+
$test = 'a\\b';
|
11
|
+
//この正規表現では、「\,:,?,<,>,|」と「./」と「../」を検索します。
|
12
|
+
//(あえてスラッシュは正規表現の検索対象としていません。)
|
13
|
+
$a = preg_match('#[\\\\:?<>|]|\.{1,2}/#', $test,$m);
|
14
|
+
```
|
8
15
|
###追記
|
9
16
|
```php
|
10
17
|
/**
|
@@ -33,5 +40,4 @@
|
|
33
40
|
}
|
34
41
|
return false;
|
35
42
|
}
|
36
|
-
|
37
|
-
```
|
43
|
+
```
|
1
回答内容を追記
answer
CHANGED
@@ -4,4 +4,34 @@
|
|
4
4
|
function check($s){
|
5
5
|
return strlen($s) !== strlen(mb_convert_encoding(mb_convert_encoding($s,'SJIS','UTF-8'),'UTF-8','SJIS'));
|
6
6
|
}
|
7
|
+
```
|
8
|
+
###追記
|
9
|
+
```php
|
10
|
+
/**
|
11
|
+
* 機種依存文字チェック
|
12
|
+
* @param type $text
|
13
|
+
* @return boolean
|
14
|
+
*/
|
15
|
+
function platform_dependent_characters_filter($text) {
|
16
|
+
|
17
|
+
mb_regex_encoding('UTF-8');
|
18
|
+
//$pdcでチェックの対象とする文字を設定
|
19
|
+
$pdc = '⑩⑪⑫⑬⑭⑯⑰⑱⑲⑳';
|
20
|
+
$pdc_array = Array();
|
21
|
+
$pdc_text = str_replace(array("\r\n", "\n", "\r"), '', $text);
|
22
|
+
//チェック対象を配列化
|
23
|
+
while ($iLen = mb_strlen($pdc, 'UTF-8')) {
|
24
|
+
array_push($pdc_array, mb_substr($pdc, 0, 1, 'UTF-8'));
|
25
|
+
$pdc = mb_substr($pdc, 1, $iLen, 'UTF-8');
|
26
|
+
}
|
27
|
+
|
28
|
+
//特殊文字が無いかどうかチェックする
|
29
|
+
foreach ($pdc_array as $value) {
|
30
|
+
if (preg_match("/(" . $value . ")/", $pdc_text)) {
|
31
|
+
return true;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
return false;
|
35
|
+
}
|
36
|
+
|
7
37
|
```
|