SQL to find upper case words from a column

后端 未结 7 1459
南笙
南笙 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:28

    It is possible to achieve this thanks to the REGEXP_REPLACE function:

    SELECT REGEXP_REPLACE(my_column, '(^[A-Z]| |[a-z][A-Z]*|[A-Z]*[a-z])', '') AS Result FROM my_table
    

    It uses a regex which replaces first upper case char of the line and converts every lower case char and space with blanks.

提交回复
热议问题