|
-
Sep 25th, 2010, 01:21 PM
#1
Thread Starter
Lively Member
Regular Expressions
I want to create Regular Expression for phone number and valid digits allowed are (,),-,+,0----9. If the left bracket ( is there,then its necessay that right bracket is also there. How to create the Regular Expression for the above. I dont know how to create the regular Expression,they just kill me.
-
Sep 25th, 2010, 02:02 PM
#2
Frenzied Member
Re: Regular Expressions
hay,
this will return true,
Code:
string phoneNumber = "444-6666";
bool val = System.Text.RegularExpressions.Regex.IsMatch(phoneNumber, "^[0-9,()+-]{8,12}$");
if you just write the formula that you want for the phone i think i can help
You Don't Have to Rate Me.
I'm Not a Civilized Man I'm the Civilization it self
White or Black, Living or Dieing and 0 or 1 that's MY life
iam an Object in Object Oriented Life
my blog : http://refateid.blogspot.com/
twitter : @avrail
010011000111010101110110001000000100110101111001001000000101000001100011 
-
Sep 27th, 2010, 01:34 AM
#3
Re: Regular Expressions
Hey,
Check the link in my signature, there are a number of Regex related links in it.
Specifically, Regex Lib, it has a own library of Regular Expressions, so it is likely that you will find the one that you need there.
You might also want to check this out:
http://gskinner.com/RegExr/
A very helpful online regular expression checker.
Hope that helps!
Gary
-
Oct 5th, 2010, 09:45 AM
#4
Thread Starter
Lively Member
Re: Regular Expressions
HI avrail, I want the following validations to apply -
(0124) - 900000
(91) + 78777
If I use ur code and write (1234) - 7878 in textbox I am getting false. I want that if the number is in the format as above,it will return true.. and one thing more I have to limit the numbers entered are just 10 exclusing () + -
-
Oct 5th, 2010, 12:55 PM
#5
Frenzied Member
Re: Regular Expressions
hay mansi,
sorry i wasn't here
Code:
string phoneNumber = "(0123) - 123456";
bool val = System.Text.RegularExpressions.Regex.IsMatch(phoneNumber
, @"^(\(\d{2}\)\s?[-|+]\s?\d{5,6}|\(\d{4}\)\s?[-|+]\s?\d{5,6})$");
Last edited by avrail; Oct 5th, 2010 at 01:00 PM.
You Don't Have to Rate Me.
I'm Not a Civilized Man I'm the Civilization it self
White or Black, Living or Dieing and 0 or 1 that's MY life
iam an Object in Object Oriented Life
my blog : http://refateid.blogspot.com/
twitter : @avrail
010011000111010101110110001000000100110101111001001000000101000001100011 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|