.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

what is the "." for in a phone number regex?

Posted By:      Posted Date: October 07, 2010    Points: 0   Category :.NET Framework
      string phone = "973 555-7241";
      string pat = @"^\d{3}[- .]?\d{3}[- .]?\d{4}$";
      Match rv = Regex.Match(phone, pat);

What does the "." in the section "[- .]" of the above regex pattern mean?

I understand "." to mean 'any char but newline". Square brackets contain a set of chars, any of which can match the current character. [ -] means "either space char or dash char".  I read "[- .]" to mean any of "dash, space or any char other than new line".  But something like 973x555-1212 does not match the regex.



View Complete Post

More Related Resource Links

Getting IMEI number of a mobile phone

I am developing an  asp.net web application which supplies content to mobile phones  , Im trying to get the imei number of  mobile phones using thier numbers. How can we achieve this?

Regex for checking number greater than 9

Hi All , I need to write a regex which can check for a number greater than equal to 9 .  

[regex] Extracting number preceding a particular text (in this case area unit).

Hi there, I'm looking for a regex to extract two numbers from the same text (they can be run independently, no need to extract them both in one go. I'm using yahoo pipes. Source Text: S$ 5,200 / month Negotiable, 1,475 sqft / 137 sqm (built-in) - Apartment, 10 Anson Road (D02) Need to extract as a number: 1,475 and also (but can be extracted on a separate instance) Need to extract as a number: 137 any guidance will be greatly appreciated. thanks in advance Paco

Format phone number in asp.net textbox control

Hi,  I have a <asp:textbox> control, I want to display text as a phone number format like phone number mask. Anybody can help on this. Thanks in advance.

Regex: password must contain one number, one letter, and 0 or more special chars


I'm trying to validate a password, and I'm almost there, but need some help finishing it off. Here's what I need:

1) 6-10 characters

2) At least one alpha AND one number

3) The following special chars are allowed (0 or more): !@#$%

Here's what I have:


Passwords that should work: test1ng, abc123, abc1234567, 123abc, abc!123, !@#$%1abcd, !@#$%a9

Passwords that shouldn't work: a, 1, a1, 1$, %, abc!@#, 012345, a1234+, abcde, test*ng, abcde!, !@#$%!, a1234567890, testit!0987, 1abcdefghij

It works on all my test cases, except it allows "a1234567890", "testit!0987", and "1abcdefghij", none of which should be allowed, since they contain more than 10 chars. What am I missing?

Regex match a number between 100 and 200 and no letters


Hello i`m new in regex and i relly need some help how to fin a solution in this problem

match a number between 100 and 200 inclusive and no letters allowed

Thx in advance hope some one will help me with this

Best regards


Phone number dialer


Hi everybody

I need to make an application that dial a phone number and then register the response status for statistics issue (if it was connected, if the line is busy, etc)

How can I manage those signals? May I use SerialPort object?

Please, if you have some example code, I will appreciate so much

Thanks in advance

Dr CRs


Retrieve caller ID number from VOIP phone

I am wanting my program to be able to retrieve the caller ID number when a call is received through my VOIP phone.  I know this is possible but I need someone to point me in the right direction of how I would go about this.

Thanks for any help

User profile sync - Replication of manager, physical office location and work phone number back to a


SharePoint 2010 user profile synchronisation successfully up and running following the super guide from Harbar (thank you!).

Setup the property for first name to replicate back into active directory and this has worked perfectly.

Now trying to configure the following functionality and getting issues.

1] Allow the users to edit the manager property and replicate back into AD

2] Allow the users to change their phone number and replicate back to active directory

3] Allow the users to edit the office location using a drop down list.

So these are the problems

1] Allow the users to edit the manager property and replicate back into AD

Have made the property editable and the users can change it.  The org chart browser works using the new values.  The profile property, however, will not allow you to set is as 'user overridable' in central admin and it never goes back into AD.  Indeed there is a warning displayed in the users my site to this effect.

2] Allow the users to change their phone number and replicate back to active directory

Have made the property editable and the users can change it.  The profile property, however, will not allow you to set is as 'user overridable' in central admin and it never goes back into AD.  Indeed there is a warning displayed in the users my site to t

Phone Number Input Mask


I am fairly new to MVC.  I have a html helper textbox for phone number .  I am trying to apply a input mask of xxx-xxx-xxxx to th phone number html helper.  I even downloaded the Digital Bush Masked Input Plugin but it doesn't even work.  Can someone provide me some guidance on this matter.

Want to implement valdiation that phone number entered should be minimum 10 digits


I have text box where user enter phone number and I have to implement that logic that phone number entered should be of minumum 10 digits.Otherwise it shows error message.User can enter phone number with -,+,. pattern.
So I have created key like


but it still allows user to enter phone digit less than 10.I thought giving value like
'^[\d{10,10}\-\+\.]+$' means user can enter only 10 digits and user can enter phone number with -,+ and . expression.Can anyobdy help me with the regex pattern.Where user can enter only phone number with minimum 10 digit and +,- amd . can be used and there should be no manixmum limit for entering digit.

how to use regex to identify the number of links in html source code


Hi, all, how to count the number of links in a piece of html source code, is it possible to use regex, for example, create a regex "href" and to count for matches? thanks in advance.

for example, a segment of html code like this:

<TD style="PADDING-RIGHT: 3px" width=150><A id=a588660 onclick="return Evar16_tracking('588660');" href="/products/shprodde.asp?sku=588940"><IMG style="BORDER-BOTTOM: #ccc 1px solid; BORDER-LEFT: #ccc

Regular Expression For US Phone Number in C#?

Hello friends,

If you know regular expression for US phone validation please let me know. I have used

^[01]?[- .]?(\([2-9]\d{2}\)|[2-9]\d{2})[- .]?\d{3}[- .]?\d{4}$  expression . But it is fine for 10 digit numbers validation. I may have 12 digit numbers like 23-456-213-765  .  What is the regular expression for this?

Regex for number seq. between 1 -16 eg: 1,2, 4-8,12


Can some one help about for the reular expression for a range of Numbers between 1 -16. The possibility of occurance of these numbers are like a printing document sequnce eg: 1, 2-10, 16 or 1, 4,  5-12 soon




Set contents of textbox when click to call phone number


So I have a text box


li class="textwidth">   
<label class="labelwidth" for="txtLine1">
    Phone #:</label>   
<asp:TextBox ID="txtPhoneNumber" runat="server" Width="202px" onkeydown="javascript:backspacerDOWN(this,event);" onkeyup="javascript:backspacerUP(this,event);" CssClass="inputwidth"></asp:TextBox>

When they click on this or when they click on something by this textbox I want it to call the phone number.

The ACTUAL phone number is filled in the pageload event:

If Not (SPPhone Is Nothing) Then
            Me.txtPhoneNumber.Text = SP.PhoneNumber

I know about the <a href="tel but I don't understand how I can implement it, since I don't know the phone number until the page actually loads.

Thanks for any and all help!

Building a Searchable Phone Directory with Windows SharePoint Services

I want to continue to build out the intranet site we've started in our previous articles. A standard item in every intranet is a staff/employee list. Most companies implementing Windows SharePoint Services (WSS) are large enough to have a database that contains all employees. We will use the aggregation features of SharePoint to include data from this database into our intranet.

Use a Windows Mobile Phone as a Bluetooth Modem

Many Windows Mobile Pocket PC Phones and Windows Mobile Smartphones can be connected to a Windows PC via Bluetooth for use as a wireless dial-up modem. If your Windows Mobile device supports Bluetooth Dial-Up Networking, or Bluetooth DUN, and your Windows PC Bluetooth-enabled, you have everything you need.

In this tutorial, we'll show you how to use Windows Mobile Pocket PC Phones or Smartphones as a Bluetooth modem for Windows XP PCs.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend