Solved

URGENT: Easy Regex Question

Posted on 2004-04-07
4
183 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
  • 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 500 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Article by: Ivo
Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now