oracle中文与数字正则实例代码

WBOY
Release: 2016-06-07 17:45:45
Original
1194 people have browsed it

在oracle中regexp_like(VALID_STR ,'^[+-]?\d+(\.\d)?\d*$'); 是用来正数字的,中文用new Regex("[\u4e00-\u9fa5]+", RegexOptions.Compiled);来处理

在oracle中regexp_like(VALID_STR ,'^[+-]?\d+(\.\d)?\d*$'); 是用来正数字的,中文用new Regex("[\u4e00-\u9fa5]+", RegexOptions.Compiled);来处理

在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 {
if (regex.ismatch(strsource.substring(i, 1)))
{
nlength++;
}
}

return nlength;
}

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!