LoginSignup
40
35

More than 5 years have passed since last update.

@"Xcodeで日本語リテラルをあぶり出す呪文";

Last updated at Posted at 2015-06-12

Xcodeの正規表現検索でプロジェクト内の日本語(全角文字)を含む文字列(リテラル)を一挙に検索します。ローカライズするときに一時的に日本語で書いておいた場所を見つけるのに便利です。

コピペしてお使いください

objc

(^|[^%])\@\"[^\"]*[^\x01-\x7E][^\"]*\"

swift

\"[^\"]*[^\x01-\x7E][^\"]*\"

マッチ例

一文字でも日本語(全角文字)を含んでいるとマッチします。
@"あ", @"あああ", @"abcあefg", @"abcdefあ"

検索方法は以下の画像を参照

xcode_search_regex.png

全体検索のショートカットは Cmd+Shift+F が便利です。

応用編 (Objective-C)

代入、引数、三項演算子など特定のパターンを指定して検索可能です。

= @"文字列"

\=\s*\@\"[^\"]*[^\x01-\x7E][^\"]*\"

:@"文字列"

\:\s*\@\"[^\"]*[^\x01-\x7E][^\"]*\"

? @"文字列"

\?\s*\@\"[^\"]*[^\x01-\x7E][^\"]*\"

, @"文字列"

\,\s*\@\"[^\"]*[^\x01-\x7E][^\"]*\"

@"文字列";

(^|[^%])\@\"[^\"]*[^\x01-\x7E][^\"]*\"\s*\;

= @"文字列" もしくは :@"文字列"

(\=\s*\@\"[^\"]*[^\x01-\x7E][^\"]*\")|(\:\s*\@\"[^\"]*[^\x01-\x7E][^\"]*\")

40
35
1

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
40
35