由于堆栈溢出,我得到了标准的reg表达式
to eliminate -
a) special characters
b) digits
c) more than 2 spaces to single space
to include -
d) - (hyphen)
e) ' (single quote)
SELECT ID, REGEXP_REPLACE(REGEXP_REPLACE(forenames, '[^A-Za-z-]', ' '),'\s{2,}',' ') , REGEXP_REPLACE(REGEXP_REPLACE(surname, '[^A-Za-z-]', ' '),'\s{2,}',' ') , forenames, surname from table1;
谢谢。
答案 0 :(得分:1)
Oracle设置:
CREATE TABLE test_data ( id, value ) AS
SELECT 1, '123a45b£$- ''c45d@{e''' FROM DUAL
查询:
SELECT ID,
REGEXP_REPLACE(
value,
'[^a-zA-Z'' -]| +( )',
'\1'
)
FROM test_data
输出:
ID | REGEXP_REPLACE(VALUE,'[^A-ZA-Z''-]|+()','\1') -: | :-------------------------------------------- 1 | ab- 'cde'
db <>提琴here