Created
October 6, 2015 22:08
-
-
Save MTattin/b02d260dc7061fc26909 to your computer and use it in GitHub Desktop.
PHP正規表現での末尾改行 ref: http://qiita.com/MTattin/items/0ad9af5bbefe15c59c08
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$options = ['options' => [ | |
'flags' => FILTER_FLAG_ALLOW_OCTAL, | |
'regexp' => '/^[[:^cntrl:]]{0,5}$/u', | |
]]; | |
$var = filter_var("アイ\nウ07", FILTER_VALIDATE_REGEXP, $options); | |
echo '"アイ\nウ07"'."\n"; | |
var_dump($var); | |
echo "\n"; | |
$var = filter_var("アイウ07\n", FILTER_VALIDATE_REGEXP, $options); | |
echo '"アイウ07\n"'."\n"; | |
var_dump($var); | |
echo "\n"; | |
$var = filter_var("アイ\n", FILTER_VALIDATE_REGEXP, $options); | |
echo '"アイ\n"'."\n"; | |
var_dump($var); | |
echo "\n"; | |
$var = filter_var("\nウ07", FILTER_VALIDATE_REGEXP, $options); | |
echo '"\nウ07"'."\n"; | |
var_dump($var); | |
echo "\n"; | |
$var = filter_var("\n\nウ07", FILTER_VALIDATE_REGEXP, $options); | |
echo '"\n\nウ07"'."\n"; | |
var_dump($var); | |
echo "\n"; | |
$var = filter_var("\n", FILTER_VALIDATE_REGEXP, $options); | |
echo '"\n"'."\n"; | |
var_dump($var); | |
echo "\n"; | |
$var = filter_var("アイウ07", FILTER_VALIDATE_REGEXP, $options); | |
echo '"アイウ07"'."\n"; | |
var_dump($var); | |
echo "\n"; | |
$var = filter_var("", FILTER_VALIDATE_REGEXP, $options); | |
echo '""'."\n"; | |
var_dump($var); | |
echo "\n"; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"アイ\nウ07" | |
bool(false) | |
"アイウ07\n" | |
string(12) "アイウ07 | |
" | |
"アイ\n" | |
string(7) "アイ | |
" | |
"\nウ07" | |
bool(false) | |
"\n\nウ07" | |
bool(false) | |
"\n" | |
string(1) " | |
" | |
"アイウ07" | |
string(11) "アイウ07" | |
"" | |
string(0) "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$options = ['options' => [ | |
'flags' => FILTER_FLAG_ALLOW_OCTAL, | |
'regexp' => '/^[[:^cntrl:]]{0,5}\z/u', | |
]]; | |
以下上と同じ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"アイ\nウ07" | |
bool(false) | |
"アイウ07\n" | |
bool(false) | |
"アイ\n" | |
bool(false) | |
"\nウ07" | |
bool(false) | |
"\n\nウ07" | |
bool(false) | |
"\n" | |
bool(false) | |
"アイウ07" | |
string(11) "アイウ07" | |
"" | |
string(0) "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment