Oracle SQL - REGEXP_LIKE 包含 az 或 AZ 以外的字符

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9604727/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 14:43:12  来源:igfitidea点击:

Oracle SQL - REGEXP_LIKE contains characters other than a-z or A-Z

sqlregexoracle

提问by Tom

I would like to create a query where I select all records which contain characters that are not a-z or A-Z

我想创建一个查询,其中我选择所有包含非 az 或 AZ 字符的记录

so something like this

所以像这样

SELECT * FROM mytable WHERE REGEXP_LIKE(column_1, '![A-Z] [a-z]')

SELECT * FROM mytable WHERE REGEXP_LIKE(column_1, '![A-Z] [a-z]')

回答by Michael Berkowski

The ^negates a character class:

^否定字符类:

SELECT * FROM mytable WHERE REGEXP_LIKE(column_1, '[^A-Za-z]')

回答by Justin Cave

Something like

就像是

select *
  from foo
 where regexp_like( col1, '[^[:alpha:]]' ) ;

should work

应该管用

SQL> create table foo( col1 varchar2(100) );

Table created.

SQL> insert into foo values( 'abc' );

1 row created.

SQL> insert into foo values( 'abc123' );

1 row created.

SQL> insert into foo values( 'def' );

1 row created.

SQL> select *
  2    from foo
  3   where regexp_like( col1, '[^[:alpha:]]' ) ;

COL1
--------------------------------------------------------------------------------
abc123

回答by venky

Try this:

尝试这个:

select * from T_PARTNER 
where C_DISTRIBUTOR_TYPE_ID = 6 and
translate(C_PARTNER_ID, '.1234567890', '.') is null;

回答by Omid-RH

if you want that not contains any of a-z and A-Z:

如果您希望不包含任何 az 和 AZ:

SELECT * FROM mytable WHERE NOT REGEXP_LIKE(column_1, '[A-Za-z]')

something like:

就像是:

"98763045098" or "!%436%$7%$*#"

"98763045098" 或 "!%436%$7%$*#"

or other languages like persian, arabic and ... like this:

或其他语言,如波斯语、阿拉伯语和……像这样:

"???? ????"

“?????????”