?
Solved

URGENT: Easy Regex Question

Posted on 2004-04-07
4
Medium Priority
?
190 Views
Last Modified: 2010-04-15
I'm missing something here,  I only want to allow alphanumeric characters and the period.  i have the following code

Regex regex = new Regex("[^[a-z][A-Z][0-9].]");
if(regex.IsMatch(txtName.Text) == true)

Do I need a carrot before each of those sub groups?  

(the code is not working properly).
0
Comment
Question by:jjacksn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 5

Author Comment

by:jjacksn
ID: 10780163
I would like to use hyphen as well.
0
 
LVL 12

Accepted Solution

by:
dfiala13 earned 2000 total points
ID: 10780316
Try this, you need to include all the valid characters in the brackets, and the period is a special character you have to escape it... (as is the hyphen)

[^A-Za-z0-9\.\-]
0
 
LVL 5

Author Comment

by:jjacksn
ID: 10780337
for future reference, how do I undo the negation?  
0
 
LVL 12

Expert Comment

by:dfiala13
ID: 10780355
pop out the ^

[A-Za-z0-9\.\-]

will match any string that has one of the characters in brackets
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question