SQL to find upper case words from a column

后端 未结 7 1492
南笙
南笙 2020-12-10 02:56

I have a description column in my table and its values are:

This is a EXAMPLE
This is a TEST
This is a VALUE

I want to display only EXAMPLE

7条回答
  •  青春惊慌失措
    2020-12-10 03:27

    This should do the trick:

    SELECT SUBSTR(REGEXP_REPLACE(' ' || REGEXP_REPLACE(description, '(^[A-Z]|[a-z]|[A-Z][a-z]+|[,])', ''), ' +', ' '), 2, 9999) AS only_upper
    FROM ( 
        select 'Hey IF you do not know IT, This IS a test of UPPERCASE and IT, with good WILL and faith, Should BE fine to be SHOWN' description
        from dual 
    )
    

    I have added condition to strip commas, you can add inside that brakets other special characters to remove.

    ONLY_UPPER
    -----------------------------------
    IF IT IS UPPERCASE IT WILL BE SHOWN
    

提交回复
热议问题