简体   繁体   English

用于验证字符串的正则表达式

[英]Regular expression to validate a string

What should be the regular expression if i need to show the error if the string contains character other than letters, digits, blank, underscore (_), dash (-), dollar sign ($), at sign (@),open curly brace ({), close curly brace (}) and pound sign (#) 如果字符串中包含字母,数字,空格,下划线(_),破折号(-),美元符号($),符号(@),开卷的字符以外的其他字符,则我需要显示错误,则正则表达式应该是什么大括号({),大括号(})和井号(#)

Regex.IsMatch(myString, ?????????, RegexOptions.IgnoreCase)

Thanks.. 谢谢..

You can use this expression : 您可以使用以下表达式:

^[a-zA-Z0-9\ _#\-\$\{\}@]*$

PS : Usefull tool to create REGEX : https://www.debuggex.com/ PS:创建REGEX的有用工具: https ://www.debuggex.com/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM