Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,

I want a regular expression that will accept a string with digit(0-9) along with "-", "+", "(", ")", "." , "," and space .It WILL BE a STRING with random combination of above characters.

Thanks in Advance.
Posted

I use TXT2RE Regular Expression Generator to quickly create Regular Expressions.
 
Share this answer
 
Use the following approach:
C#
string input = ...;
string pattern = @"^[\s0-9"+Regex.Escape("-+().,")+"]+$";
if (Regex.Match(input, pattern).Success) { /* success actions... */ }

Cheers
Andi
 
Share this answer
 
v2

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