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

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 」を選択して、そのテキストをすべて置換します。

「コードの編集方法」、 「検索方法」、および「コードの編集も参照してください

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.