Skip to content

Instantly share code, notes, and snippets.

@hotwatermorning
Created November 14, 2017 11:19
Show Gist options
  • Select an option

  • Save hotwatermorning/287a79a2bc33b4e2fdf09cb6adc2f7d7 to your computer and use it in GitHub Desktop.

Select an option

Save hotwatermorning/287a79a2bc33b4e2fdf09cb6adc2f7d7 to your computer and use it in GitHub Desktop.
pcregrepでunicode文字列を検索する
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