Oracle REGEXP_INSTR() and “a-z” character range doesn't match as expected

后端 未结 2 1755
说谎
说谎 2021-01-22 08:04

I want to use REGEXP_INSTR() within an oracle database to check for lower/uppercase characters. I\'m aware of [:upper:] and [:lower:] POSI

2条回答
  •  滥情空心
    2021-01-22 08:48

    The reason for the behavior is the collation rules. See the NLS_SORT documentation:

    • If the value is BINARY, then the collating sequence for ORDER BY queries is based on the numeric value of characters (a binary sort that requires less system overhead).
    • If the value is a named linguistic sort, sorting is based on the order of the defined linguistic sort. Most (but not all) languages supported by the NLS_LANGUAGE parameter also support a linguistic sort with the same name.

    Set the NLS_SORT to BINARY so that the [A-Z] could be parsed in the same order as in the ASCII table,

    alter session set nls_sort = 'BINARY'
    

    Then, you will get consistent results.

    See the online demo.

提交回复
热议问题