package com.nortl.namacngsg.util;
public class CommonUtil
{
// 将字母转换为数字A-Z转换为1-26
public static String letterToNum(String input)
{
String reg = "[a-zA-Z]";
StringBuffer strBuf = new StringBuffer();
input = input.toLowerCase();
if (null != input && !"".equals(input))
{
for (char c : input.toCharArray())
{
if (String.valueOf(c).matches(reg))
{
strBuf.append(c - 96);
} else
{
strBuf.append(c);
}
}
return strBuf.toString();
} else
{
return input;
}
}
}
将字母转换为数字A-Z转换为1-26
最新推荐文章于 2024-10-08 15:50:58 发布