Created
November 14, 2017 11:19
-
-
Save hotwatermorning/287a79a2bc33b4e2fdf09cb6adc2f7d7 to your computer and use it in GitHub Desktop.
pcregrepでunicode文字列を検索する
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
| https://insideflag.blogspot.jp/2013/10/grep-punicode.html | |
| ``` | |
| UTF-8モードについて調べるためman pcreしてみると、non-UTF-8 modeではUnicodeプロパティのテストは255以下のコードポイントに制限されると書いてあったので、GNU grepでもなんとかしてUTF-8モードにする必要がある。さらにドキュメントを読むと、パターンの先頭に(*UTF8)があればUTF-8モードになるとのことなので試してみる。 | |
| $ echo "あ" | ggrep -P "(*UTF8)\p{Hiragana}" | |
| あ | |
| できた。だけど英数記号混じりで毎回7文字もタイプするのはだるい。 | |
| ``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment