正規表現を使った検索と置換

Search Results ビューで正規表現を使ってファイルを検索・置換する。

Qt Creator で使用される正規表現は、Perl の正規表現をモデルにしています。正規表現の使い方については、QRegularExpression を参照してください。

例えば、等号チェック (foo == bar) を関数 (foo.equals(bar)) に置き換える場合です:

  1. 置換を取り消すことはできないので、変更をバージョン・コントロールにコミットしてください。
  2. Ctrl+Shift+F を選択するか、Edit >Find/Replace >Advanced Find >Open Advanced Find と進み、Search Results を開きます。

    検索結果ビューの正規表現

  3. Scope で、検索に適したものを選択する。
  4. Use regular expressions を選択する。
  5. Search for に次のテキストを入力する:
    if \((.*) == (.*)\)
  6. Search & Replace を選択すると、検索結果のリストが表示されます。

    正規表現の検索結果

  7. Replace with に、次のテキストを入力します:
    if (\1.strictlyEquals(\2))
  8. Replace を選択すると、そのテキストがすべて置換されます。

How To: Edit Code」、「How To: Search」、「Edit Mode」も参照してください

Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.