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

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -