문제

My problem is that I need to remove all invalid characters from a column, but the dash and brackets characters are valid ones.

as so far my sql is:

SELECT REGEXP_REPLACE(column_name, '[^][-0-9a-z]' , '') FROM table_name;

but this doesn't include the dash character.

and:

SELECT REGEXP_REPLACE(column_name, '[^-][0-9a-z]' , '') FROM table_name;

this isn't good either.

도움이 되었습니까?

해결책

There are 2 solutions for this:

1, use one of them at start and other at the end of the Matching Character List:

SELECT REGEXP_REPLACE(column_name, '[^][0-9a-z-]' , '') FROM table_name;

2, using the POSIX Collating Element Operator [.character.]:

SELECT REGEXP_REPLACE(column_name, '[^[.].][.[.][.-.]0-9a-z]' , '') FROM table_name;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top