?
Solved

URGENT: Easy Regex Question

Posted on 2004-04-07
4
Medium Priority
?
189 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

764 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