华拓科技网
您的当前位置:首页oracle中文与数字正则实例代码

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

来源:华拓科技网


解决正则中文

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

显示全文