简体   繁体   中英

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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