Home  >  Article  >  Database  >  oracle中文与数字正则实例代码

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

WBOY
WBOYOriginal
2016-06-07 17:45:451217browse

在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;
        }

Statement:
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
Previous article:Oracle碎片整理Next article:Oracle的独立事物使用教程