It should validate something like this:
a,b,c,d,1,2,3,w,f,x,-,=,d
Accepted only one char and next is comma.
Bad example:
adc,1,2,345,flos
I think of thsi:
@"([*{1}]+[,{1}])+"
but this not work.
Try ^[^,](,[^,])*$
. The structure is as follows:
[^,]
(,[^,])*
If you want to match an empty string as well you should make the whole expression optional:
^([^,](,[^,])*)?$
如果您想char with comma
从允许的char with comma
找到任何组,简单的方法是
(a|b|c|d|1|2|3|w|f|x|\-|\=)\,
It gives you what you want i guess :
bool isMatched = IsValid("adc,1,2,345,flos");
private bool IsValid(string value)
{
return Regex.IsMatch(value, @"^([^,](,[^,])*)?$");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.