.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

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -