问题
If i have a clob field that contains the following text
Note - The @ character denotes an empty line (with or without spaces).
@
@
AB DF SDF DFDS F
FDSFSDF
@
DFSFDSFSDF
@
DSFDS
@
FDSF
DSFS
DF
@
@
@
@
How can i modify it so that all the empty lines at the beginning of the text are removed (i.e. all empty lines up to the first line where there is content)
I know there are several functions that Oracle provide for replacing strings but i am struggling to use any of them when i can ignore the empty lines between the text and the ones at the end of the text. The output should be as shown below.
AB DF SDF DFDS F
FDSFSDF
@
DFSFDSFSDF
@
DSFDS
@
FDSF
DSFS
DF
@
@
@
@
回答1:
You should be able to use the LTRIM function for this:
SELECT LTRIM (clob_field, CHR (10) || CHR (13) || ' ') FROM yourtable;
It doesn't matter what order the characters to be trimmed are in. The only caveat is that this will also remove any leading spaces from the front of the first non-blank line.
来源:https://stackoverflow.com/questions/25693113/using-sql-or-pl-sql-to-replace-empty-lines-before-start-of-content-in-clob