Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How do you search a string for a series of special characters?

Posted on 2009-04-30
6
Medium Priority
?
327 Views
Last Modified: 2013-12-17
I have users entering data in a form, but I want to verify they didn't use special characters in their entries.  I'm new to C#, but am a programmer in other languages.  

I wanted to use Regular Expressions, but not sure how to implement it.  I'm not sure how to list the characters I was to exclude but include some of the standards like left and right single quotes, left and right double quotes, single and double quotes all together, en dash and em dash, forward and back slashes, at sign, pound sign and star.
0
Comment
Question by:samac1068
6 Comments
 
LVL 20

Expert Comment

by:informaniac
ID: 24277202
You could use the RegEx.IsMatch feature
0
 

Author Comment

by:samac1068
ID: 24279275
That is helpful, but I still don't know how to write the Regular Expression string...since many of the characters I am searching for are special to RegEx.
0
 

Author Comment

by:samac1068
ID: 24279389
This is what I am using as my string so far: \\\*\^\|[-#@/'"_]
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 23

Accepted Solution

by:
Tony McCreath earned 375 total points
ID: 24279439
You can use the ^ to state not these characters. it might be easier to handle
[^a-zA-Z0-9 \.]

Open in new window

0
 

Expert Comment

by:avm7878
ID: 24281401
personally, i hate writing regex expressions. that's why i use RegexBuddy

It comes with a 7 day free trial:

http://www.regexbuddy.com/download.html
0
 

Author Comment

by:samac1068
ID: 24284814
I downloaded it today...it is really good.  Helped me out a lot.  Thanks.
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

577 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