.net - '-' not working while using Regular Expressions to match special characters, c# -
pattern
regex splregexp = new system.text.regularexpressions.regex(@"[\,@,+,\,?,\d,%,.,?,*,&,^,$,(,!,),#,-,_]"); all characters work except '-'. please advise.
use
@"[,@+\\?\d%.*&^$(!)#_-]" no need commas.
if place - inside character class, means literal dash if it's @ start or end of class. otherwise denotes range a-z. damien put it, range ,-, indeed rather small (and doesn't contain -, of course).
Comments
Post a Comment