Trim Whitespaces (New Line and Tab space) in a String in Oracle

前端 未结 14 924
挽巷
挽巷 2021-01-30 10:29

I need to trim New Line (Chr(13) and Chr(10) and Tab space from the beginning and end of a String) in an Oracle query. I learnt that there is no easy way to trim multiple charac

14条回答
  •  长情又很酷
    2021-01-30 11:12

    How about the quick and dirty translate function?

    This will remove all occurrences of each character in string1:

    SELECT translate(
               translate(
                   translate(string1, CHR(10), '')
               , CHR(13), '')
           , CHR(09), '') as massaged
    FROM BLAH;
    

    Regexp_replace is an option, but you may see a performance hit depending on how complex your expression is.

提交回复
热议问题