Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Regex
which can accept alphanumeric with special characters " A-Za-z0-9()[]+-*/%"

/^[ A-Za-z0-9()[]+-*/%]*$/
Posted
Updated 30-Dec-20 21:18pm

1 solution

Escape the ']' inside the list:
/^[ A-Za-z0-9()[\]+-*/%]*$/


If you are going to use Regular Expressions, get a copy of Expresso[^] - it's free, and it examines and generates Regular expressions.
 
Share this answer
 
v3
Comments
Member-515487 15-Dec-15 7:05am    
[RegularExpression(@"/^[ A-Za-z0-9()[\]+-*/%]*$/", ErrorMessageResourceType = typeof(ResourceFiles.EntlEngine_Resource), ErrorMessageResourceName = "RuleEditorRegexValidation")]

it not working it giving u run time exception
OriginalGriff 15-Dec-15 7:12am    
:sigh:
You can't just put the backslash in as part of a javascript string: backslash is an escape character in JS as well, so you would need two of them to pass one through to the Regex parser...
Member-515487 15-Dec-15 7:11am    
parsing "^[ A-Za-z0-9()[\]+-*/%]*$/" - [x-y] range in reverse order.
Member-515487 15-Dec-15 7:39am    
@"^[ A-Za-z0-9\[\]()*\-+/%]*$

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900