离题但相关:我正在动态创建表格,并且如果您需要它,我的代码可以帮助您,尽管表格和 PK/RK 的规则完全不同。“^[A-Za-z][A-Za-z0-9]{2,62}$”。
也许您可以使用它来激发您自己的解决方案
解码一个字符串
string edit1 = host
.Replace("qqu", "_")
.Replace("qqh", "-")
.Replace("qqp", ".")
// NOTE: qqn is reserved leading sequence
.Replace("qqt", "qqu")
.Replace("qqo", "qqp")
.Replace("qqg", "qqh")
;
if (edit1.StartsWith("qqn"))
{
edit1 = edit1.Substring(3, edit1.Length);
}
if (edit1.StartsWith("qq"))
{
edit1 = edit1.Substring(2, edit1.Length);
}
编码字符串的方法
string edit1 = this.originalName.ToLower().Trim()
.Replace("qqu", "qqt")
.Replace("qqp", "qqo")
.Replace("qqh", "qqg")
// NOTE: qqn is reserved leading sequence
.Replace("_", "qqu")
.Replace("-", "qqh")
.Replace(".", "qqp");
string test = "qq";
if (edit1.StartsWith(test))
return test + "n" + edit1;
test = "0";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "1";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "2";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "3";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "4";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "5";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "6";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "7";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "8";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "9";
if (edit1.StartsWith(test))
return "qq" + edit1;
test = "0";
if (edit1.StartsWith(test))
return "qq" + edit1;