Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 60429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:09:38+00:00 2026-05-10T18:09:38+00:00

Easy question this time. I’m trying to test whether or not a string does

  • 0

Easy question this time.

I’m trying to test whether or not a string does not contain a character using regular expressions. I thought the expression was of the form ‘[^x]’ where x is the character that you don’t want to appear, but that doesn’t seem to be working.

For example,

Regex.IsMatch('103','[^0]') 

and

Regex.IsMatch('103&','[^&]') 

both return true (I would expect false).

I started using '[^&]' and thought maybe the & needed to be escaped as \&, but it didn’t seem to make a difference.

Ideas? I assume it’s something small.

Also, I’m using .NET, so keep that in mind.

Edit1:

I found this, but it doesn’t seem to answer the issue I’m having.

Edit2:

I wanted to respond to Kevin and Joel‘s suggestions. These suggestions would indeed be faster, but they don’t accomplish the flexibility I need in this case, so if you found this question through search, definitely look to see if their answers will fit your needs. In my case, the regular expression is getting passed in to a DataTable validation method that loops through each row and verifies that the contents of that row in a specific column matches the RegEx that is getting passed in. Since I’ll be reusing this method for several other DataTables that are being validated, I wanted to:

  1. Use Regex to enable the widest range of validations, and
  2. Always look for a positive match (i.e. instead of using !Regex.IsMatch(cell, regexvariable), I wanted to rely on always being able to use Regex.IsMatch(cell, regexvariable) since the majority of DataTables invoking this method will be using the positive match instead of the negative.

Hopefully that helps.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T18:09:39+00:00Added an answer on May 10, 2026 at 6:09 pm

    Your solution is half right. The match you see is for the other characters. What you want to say is something like ‘hey! I do not want to see this character in the entire string’.

    In that case you do:

    Regex.IsMatch('103','^[^0]*$') 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 115k
  • Answers 115k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Be sure to read the PHP team's rebuttal of Google's… May 11, 2026 at 10:25 pm
  • Editorial Team
    Editorial Team added an answer -classpath tells the VM how to find classes -Dx=y sets… May 11, 2026 at 10:25 pm
  • Editorial Team
    Editorial Team added an answer You can use ptrace(2) to achieve this. It allows you… May 11, 2026 at 10:25 pm

Related Questions

Easy question this time. I'm trying to test whether or not a string does
This is a slightly.. vain question, but BuildBot's output isn't particularly nice to look
We are working with large amounts of data, all tagged in UTC (in Java).
This is a problem I'm sure is easy to fix, but I've been banging
This will surely be an easy one but it is really bugging me. I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.