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 76079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:37:02+00:00 2026-05-10T20:37:02+00:00

I haven’t used regular expressions at all, so I’m having difficulty troubleshooting. I want

  • 0

I haven’t used regular expressions at all, so I’m having difficulty troubleshooting. I want the regex to match only when the contained string is all numbers; but with the two examples below it is matching a string that contains all numbers plus an equals sign like ‘1234=4321’. I’m sure there’s a way to change this behavior, but as I said, I’ve never really done much with regular expressions.

string compare = '1234=4321'; Regex regex = new Regex(@'[\d]');  if (regex.IsMatch(compare)) {      //true }  regex = new Regex('[0-9]');  if (regex.IsMatch(compare)) {      //true } 

In case it matters, I’m using C# and .NET2.0.

  • 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-10T20:37:02+00:00Added an answer on May 10, 2026 at 8:37 pm

    Use the beginning and end anchors.

    Regex regex = new Regex(@'^\d$'); 

    Use '^\d+$' if you need to match more than one digit.


    Note that '\d' will match [0-9] and other digit characters like the Eastern Arabic numerals ٠١٢٣٤٥٦٧٨٩. Use '^[0-9]+$' to restrict matches to just the Arabic numerals 0 – 9.


    If you need to include any numeric representations other than just digits (like decimal values for starters), then see @tchrist‘s comprehensive guide to parsing numbers with regular expressions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Haven't found what i'm looking for so far. I want to redirect all my
haven't used regex replaces much and am not sure if how I have done
I haven't used C++ since college. Even though I've wanted to I haven't needed
I haven't touched sharepoint in years. If I want to setup a development environment
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Haven't seen this feature anywhere else. I know that the 32nd bit is used
I haven't used the Zend Router much yet so not sure how difficult or
I want use html5's new tag to play a wav file (currently only supported
Haven't used C++ in a while. I've been depending on my Java compiler to
I haven't used the implements keyword before, and I've been trying to use it

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.