LoginSignup
9
4

More than 5 years have passed since last update.

正規表現で日本語を探す

Last updated at Posted at 2018-09-05

正規表現で日本語を探す - (UTF-8)

マルチ言語対応

マルチ言語対応アプリの開発を行うときにテンプレートファイルに日本語が混じっていないかを探す。

[^\x01-\x7E\xA1-\xDF]+
caption.png

bash shell script example

ファイル数が少ないとき

grep -nPo "[^\x01-\x7E\xA1-\xDF]+" $(find . -type f -name "*html")

ファイル数が多いとき

find . -type f -name "*html" | xargs grep -nPoH "[^\x01-\x7E\xA1-\xDF]+"

パスに を含んでいるとき

while read file
do
  grep -nPoH "[^\x01-\x7E\xA1-\xDF]+" "$file"
done < <(find . -type f -name "*html")

while が使いたくないとき

find . -type f -name "*html" -exec grep --color=auto -nPoH "[^\x01-\x7E\xA1-\xDF]+" {} \;

less を使いたいとき

unbuffer find . -type f -name "*html" -exec grep --color=auto -nPoH "[^\x01-\x7E\xA1-\xDF]+" {} \; | less -SR
9
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
4