.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

Popular posts from this blog

mod rewrite - Doing external redirect. .htaccess NS flag not working. How to achieve similar results? -

mysql - How to insert just year and month into date field? -