Home > Net >  Remove blank (empty) lines from string SQL
Remove blank (empty) lines from string SQL

Time:02-07

I'm trying to remove blank(empty) lines from string using SQL.

I believe that solution should be something like this.

SELECT 'hello',
REPLACE('text
with
                        
blank lines


', 'PATTERN', '')

The result should be

text
with
blank lines

Text without blank (empty) lines)

CodePudding user response:

You have tagged with regex but not using regexp_replace. You could use regexp_replace to do that. ie:

SELECT 'hello',
regexp_replace('text
with

blank lines


', '^\s*?\n','','ng');

DBFiddle demo

  •  Tags:  
  • Related