oracle中文与数字正则实例代码
在oracle中regexp_like(valid_str ,'^[+-]?d+(.d)?d*$'); 是用来正数字的,中文用new regex("[u4e00-u9fa5]+", regexoptions.compiled);来处理
create or replace function isnumber(valid_str in varchar2)
return number
is
cursor valid_number is
select 1 from dual where regexp_like(valid_str ,'^[+-]?d+(.d)?d*$');
isnumber_ valid_number%rowtype;
begin
open valid_number;
fetch valid_number into isnumber_;
if (valid_number%found) then
close valid_number;
return 1;
else
close valid_number;
return 0;
end if;
end isnumber;
解决正则中文
public static int getlength(string strsource)
{
regex regex = new regex("[u4e00-u9fa5]+", regexoptions.compiled);
int nlength = strsource.length;for (int i = 0; i < strsource.length; i++)
{
if (regex.ismatch(strsource.substring(i, 1)))
{
nlength++;
}
}return nlength;
}
补充:数据库,Oracle教程