Oracle Chinese and digital Regular Expression instance code

Source: Internet
Author: User

In oracle, regexp_like (VALID_STR, '^ [+-]? \ D + (\. \ d )? \ D * $ '); is used to process positive numbers. Use new Regex ("[\ u4e00-\ u9fa5] +", RegexOptions. Compiled) in Chinese.

In oracle, regexp_like (valid_str, '^ [+-]? D + (. d )? D * $ '); is used for positive numbers, Chinese with 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;

Solve regular Chinese

Public static int getlength (string strsource)
{
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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.