# Regex search and replace inspections

You can use regular expressions to create your own search and replace inspections. These inspections can be especially useful to highlight style-based or formatting-based problems.

Procedure: Access regex inspections

1. Press `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) to open settings and then select `Editor | Inspections`.

2. From the options on the right, click ![the Add icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg).

3. Select Add RegExp Search Inspection from the list, and you’ll be directed to a dialog where you can set up your new inspection.

![Add RegExp Search Inspection](https://resources.jetbrains.com.cn/help/img/idea/2026.2/add_regex_inspection.png)

4. Select the language, use hints on the left to build a regexp, and designate the required replacement for the selected pieces of code. You can also configure the way you want the IDE to highlight them in the project.

![Search RegExp](https://resources.jetbrains.com.cn/help/img/idea/2026.2/search_regexp.png)

5. In the editor, press `Alt+Enter` (Windows), `⌥ ⏎` (macOS), `⌥ ⏎` (IntelliJ IDEA Classic (macOS)), `⌥ ⏎` (macOS System Shortcuts), `Alt+Enter` (XWin), `Alt+Enter` (GNOME), `Alt+Enter` (KDE), `Alt+Enter` (Emacs), `Alt+Enter` (Sublime Text), `⌥ ⏎` (Sublime Text (macOS)), `Alt+Enter` (NetBeans), `Alt+Enter` (Visual Studio), `⌥ ⏎` (Visual Studio (macOS)), `Ctrl+1` (Eclipse), `⌘ 1` (Eclipse (macOS)) to invoke the inspection.

![Replace with regex result](https://resources.jetbrains.com.cn/help/img/idea/2026.2/replace_with_regexp.png)

