Search and replace using a regular expression
Search and replace across files using regular expressions in the Search Results view.
Regular expressions used in Qt Creator are modeled on Perl regular expressions. For more information about using regular expressions, see QRegularExpression.
For example, to replace equality checks (foo == bar
) with a function (foo.equals(bar)
):
- Commit your changes to version control, as you cannot undo the replace action.
- Press Ctrl+Shift+F or go to Edit > Find/Replace > Advanced Find > Open Advanced Find to open Search Results.
- In Scope, select whatever is appropriate for your search.
- Select Use regular expressions.
- Enter the following text in Search for:
if \((.*) == (.*)\)
- Select Search & Replace to see a list of search results.
- In Replace with, enter the following text:
if (\1.strictlyEquals(\2))
- Select Replace to replace all instances of the text.
See also How To: Edit Code, How To: Search, and Edit Mode.
© 2024 The Qt Company Ltd. 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.