oracle PL/SQL - 我想测试一个字符串是否包含 1 个或多个小写字母

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20531614/
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-19 02:07:34  来源:igfitidea点击:

PL/SQL - I want to test if a character string contains 1 or more lower-case letters

oracleplsql

提问by tale852150

Using PL/SQL (Oracle 11gR2) I want an IF statement that tests if a string contains 1 or more lower-case letters.

使用 PL/SQL (Oracle 11gR2) 我想要一个 IF 语句来测试一个字符串是否包含 1 个或多个小写字母。

PL/SQL pseudo-code:

PL/SQL伪代码

declare
v_string varchar2(100) := 'John';

begin
if v_string contain lower-case letter then
  ... do this
else
  ... do something else
end if;
end;

/

/

采纳答案by tale852150

Answered my own question but accidentally put it in 'comments'. Here it is:

回答了我自己的问题,但不小心把它放在了“评论”中。这里是:

declare
   name varchar2(200) := 'John';
begin
 if regexp_like(name,'[:lower:]') then
   dbms_output.put_line('lowercase');
 else
    dbms_output.put_line('uppercase');
 end if;
end;

/

/

回答by David Aldridge

Test whether:

测试是否:

v_string != upper(string)

or not.

或不。

Lookout for nulls.

寻找空值。

coalesce(v_string,'X') != coalesce(upper(string),'X')

回答by Strauteka

declare
   v_name varchar2(200) := 'JOHn';
begin
 if regexp_like(v_name,'[:lower:]') then
   dbms_output.put_line('first test lowercase');
 else
    dbms_output.put_line('first test uppercase');
 end if;

 IF v_name != UPPER(v_name) THEN
  dbms_output.put_line('second test lowercase');


 ELSE
 dbms_output.put_line('second test uppercase');
 END IF;
end;

test it ... output

测试一下...输出

first test uppercase

第一个测试大写

second test lowercase

第二个测试小写

David Aldridge is correct....

大卫奥尔德里奇是对的......

回答by Maheswaran Ravisankar

if(v_string != upper(string) AND regexp_count(string,'[[:alpha:]]' > 0 )
then
   -- Has Lower case
end if

It also checks, if the string contains any alphabets!

它还检查字符串是否包含任何字母!