Created
September 27, 2022 10:49
-
-
Save matsuoshi/e06ed942d84d0c16fe48fa691f2f8838 to your computer and use it in GitHub Desktop.
正規表現の uフラグ
This file contains hidden or 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
| <?php | |
| $subjects = [ | |
| 'zenkaku', | |
| 'hankaku', | |
| 'あいうえお' | |
| ]; | |
| foreach ($subjects as $subject) { | |
| preg_match('/^[a-z]+$/', $subject, $match); | |
| var_dump($match); | |
| } | |
| echo '--------', PHP_EOL; | |
| foreach ($subjects as $subject) { | |
| // `/u` をつける | |
| preg_match('/^[a-z]+$/u', $subject, $match); | |
| var_dump($match); | |
| } |
Author
matsuoshi
commented
Sep 27, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment