Click here to Skip to main content
15,911,360 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi friends,

Can anybody please give me Regex Expressions to match these...

The number should be more than three digits..
The number should not exceed 20 digits..

+41 5203 789850 should match
+41 523 - 586 - 789 -789 should match
10.20.13.20:8080 should not match
123.45.20.125 should not match
+91 9544337661 should match
+91 (475) 2250010 should match
1200 should match

Thanks

additional information by the OP copied from comment below
sure....

C#
var exp = new Regex(@"#?[0-9\s\-\(\)]{4,20}", RegexOptions.IgnoreCase);


What I want is to get the numbers having more than 4 digits.
But its counting everything in the expression... For eg: It returns (20) and 20 too (since it has space)....
How can I choose only if the numbers are more than 4 digits, and select the rest if it contains this special characters...
Posted
Updated 26-Aug-13 21:58pm
v2
Comments
Nelek 26-Aug-13 9:21am    
This is not how CP usually works. Most important goal here is to learn and help learning.
You are supposed to try it on your own, and come here when you got stuck with something, with a concrete question about your code, design, etc.
Please have a look to What have you tried?[^] to see a good explanation about what I mean.
Don't forget people here don't get payed. And besides, if we give you a ready-to-go solution, it is not going to help you because you are not going to learn anything from it.
Yesudasan Moses 26-Aug-13 9:44am    
yea... thanks :)
I have tried something but nothing works....
phil.o 26-Aug-13 10:36am    
May we know what 'something' is, to start from it and help you getting to the correct expression ?
Yesudasan Moses 26-Aug-13 10:39am    
sure....

var exp = new Regex(@"#?[0-9\s\-\(\)]{4,20}", RegexOptions.IgnoreCase);

What I want is to get the numbers having more than 4 digits.
But its counting everything in the expression... For eg: It returns (20) and 20 too (since it has space)....
How can I choose only if the numbers are more than 4 digits, and select the rest if it contains this special characters...
Nelek 27-Aug-13 3:59am    
That was exactly what I asked for :P

1 solution

check this link[^]
 
Share this answer
 

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