简体   繁体   中英

how to allow accented charaters in oracle using regexp_replace in oracle?

Case: To accept person_name satisfying following criteria:

  1. Allows any alphabetic symbols
  2. Space
  3. Dash
  4. Apostrophe
  5. Accent grave

Some pre-calculation has been performed to store the name in the string "PERSON_NAME"

LOGIC: SUBSTR(REGEXP_REPLACE(PERSON_NAME,'[^A-Za-z .`''-]+',''),0,50)

SELECT SUBSTR(REGEXP_REPLACE('cafè','[^A-Z|a-z| |.|`|''|-]+'),0,50) 
    FROM dual;

Passing almost all cases except in case of accented characters:

For example:

Expected result: cafè [ie symbol above e ` should not be filtered out]

Actual Result: caf

You can use :

select SUBSTR(REGEXP_REPLACE('cafè-` t *'' {','[[:digit:]]') ,0,50) as "String"
  from dual;

String
--------------
cafè-` t *' {

since there's no information about numeric expressions in your restriction list.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM