Skip to content

Instantly share code, notes, and snippets.

@velppa
Last active December 15, 2015 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save velppa/5308630 to your computer and use it in GitHub Desktop.
Save velppa/5308630 to your computer and use it in GitHub Desktop.
Replaces multiple newlines into single one
with a as
(select q'{
Line 1
Line 2
Line 3
Line 4
Line 5
}' l from dual
)
select regexp_replace(a.l,'('||CHR(10)||'[[:space:]]*'||CHR(10)||'){2,}',CHR(10)||CHR(10)) a
from a;
@velppa
Copy link
Author

velppa commented Apr 4, 2013

Assumes that new line is \n symbol. If it's \r\n, then replace CHR(10) with CHR(13)||CHR(10).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment