Off topic but related: I'm creating tables dynamically and have code that may help you if you need it, though the rules for tables and PK/RK are quite different. "^[A-Za-z][A-Za-z0-9]{2,62}$"."
Perhaps you can use this to inspire your own solution
Decode a string
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);
}
Method to Encode a string
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;