需要一些正则表达式的帮助。
到目前为止,我的代码允许有限数量的特殊字符。但是,我不知道如何让它只允许它们在中间而不是结束。
有人可以帮我弄清楚那部分吗?
这是我在 c# 中使用的代码:
Regex uRLToVal= new Regex("^[A-Za-z0-9-_.+!*]*$");
if (!uRLToVal.IsMatch(this.mainURL))
{
results.AddPropertyError("Your Entry can only contain letters, numbers, underscores, periods, plus, exclamation marks and hypens. Special characters should always be inside numbers or letters. Example: v!v is OK BUT NOT !vv or vv!");
}