c# - Allow underscore "_" as a special character -


this expression, not accepting "_" special character

{(?=.{8,})(?=(.*\d){0,})(?=(.*\w){1,})} 

when set conditions inside pattern, not forget consume characters, add .+ capture 1 or more symbols, or .* capture 0 or more characters:

{(?=.{8,})(?=(.*\d){0,})(?=(.*[^a-za-z0-9]){1,}).+} 

however, if want require string have @ least 1 digit , @ least 1 non-word symbol (excluding underscore), i'd suggest using

{(?=.{8,})(?=(?:.*\d){0,})(?=(?:.*[^a-za-z0-9]){1,}).+} 

see demo.


Popular posts from this blog

javascript - Js, document.getElementById("ID").innerHTML, error -

jquery - jqGrid update specific column data with out refreshing the entire column? -

objective c - Is there a way in OCMockito to make stubs fail when an unknown method is called? -