'How to Find or Replace New Line Character in ORACLE SQL Developer

When I press Ctrl + F in SQL Developer the Find/Replace tool comes up. I need to replace a new line with ',' . I can't figure out how to search for a new line. In SSMS I could hit Ctrl+F and enter \n in the find or replace field if I wanted to find or replace a new line. How do I do this with ORACLE SQL Developers Find and Replace tool?



Solution 1:[1]

When you open Find/Replace, then:

  • enter \n into the search field
  • enter , into the replace field
  • push the Regular expresssion button in the toolbar (it is 4th in my 18.3 version, after Match Case, Whole word, Highlight)
  • push the "Replace all" button in the toolbar

Solution 2:[2]

Littlefoot's answer should be correct, only, because of a long standing bug (years) it doesn't work.

To replace two consecutive blank lines with one, I replace three newlines with two newlines:

  1. Enter \n\n\n in Search Box
  2. Select the ".*" regular expression button, 4th to right of Search box
  3. Enter \n\n in Replace box
  4. Select the "\?" substitute escaped characters button 2nd to right of Replace box
  5. Click Replace or Replace All

I end up with the both blank lines removed and the comment line, the nn, and the code line all concatenated. This happens whether or not I click the substitute escaped characters:

BEFORE

-- DDL for Index PK_APP_SYSTEMVAR



CREATE UNIQUE INDEX pk_app_systemvar ON app_systemvar (var_id);

AFTER:

-- DDL for Index AK_PACKETnnCREATE UNIQUE INDEX pk_app_systemvar ON app_systemvar (var_id);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Littlefoot
Solution 2