Windows Develop Bookmark and Share   
 index > Windows Forms General > Regular Expression To Accept only (.) ?
 

Regular Expression To Accept only (.) ?

If any one knows what is the regular expression to accept only (.) For Example i have years of experience 4.5 then it should allow special character only . other than . if i enter any other spl character it should give error. Please help me in this.
Ganapatisb  Monday, September 07, 2009 1:30 PM
Hi,
I hope it will help you
 Regex regex = new Regex("^[a-zA-Z0-9\.]*$");
            if (regex.IsMatch(textBox1.Text))
            {
                errorProvider1.SetError(textBox1, String.Empty);
            }
            else
            {
                errorProvider1.SetError(textBox1,
                      "Error");
            }

Best Regards, C.Gnanadurai ----------------------- Please mark the post as answer if it is helpfull to you
Gnanadurai  Monday, September 07, 2009 1:56 PM
Hi,
I hope it will help you
 Regex regex = new Regex("^[a-zA-Z0-9\.]*$");
            if (regex.IsMatch(textBox1.Text))
            {
                errorProvider1.SetError(textBox1, String.Empty);
            }
            else
            {
                errorProvider1.SetError(textBox1,
                      "Error");
            }

Best Regards, C.Gnanadurai ----------------------- Please mark the post as answer if it is helpfull to you
Gnanadurai  Monday, September 07, 2009 1:56 PM
Hi,

Yes I think you can also escape the period using a backslash

\.
www.dsmyth.net | www.dsmyth.net/wiki
Derek Smyth  Monday, September 07, 2009 3:58 PM

The following shows some information about Regular Expressions. At the end of this KB, it gives some useful links. Hope this helps.

How to match a pattern by using regular expressions and Visual C#

http://support.microsoft.com/kb/308252/en-us

By the way, you can get more information from Regular Expressions Forum:

http://social.msdn.microsoft.com/Forums/en-US/regexp/threads

Best regards,

Ling Wang


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Monday, September 14, 2009 3:33 AM

You can use google to search for other answers

Custom Search

More Threads

• question of DoubleClick on ListView, need help!!
• Datepicker with typing
• Tree View - remember selected node
• Unable to cast COM object of type 'System.__ComObject' to class type...???
• DoDragDrop() Target Path/Location...
• Datagridview questions
• limitation of the wordwrap property in multiline control?
• Threading Help (without a clue)
• How to simulate the action : drag-drop a item from a listbox to another?
• Binding to Property of Property