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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:46:55+00:00 2026-06-16T03:46:55+00:00

My Regex is removing all numeric (0-9) in my string. I don’t get why

  • 0

My Regex is removing all numeric (0-9) in my string.
I don’t get why all numbers are replaced by _

EDIT: I understand that my “_” regex pattern changes the characters into underscores. But not why numbers!

Can anyone help me out? I only need to remove like all special characters.

See regex here:

 string symbolPattern = "[!@#$%^&*()-=+`~{}'|]";
Regex.Replace("input here 12341234" , symbolPattern, "_");

Output: "input here ________"
  • 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. Editorial Team
    Editorial Team
    2026-06-16T03:46:57+00:00Added an answer on June 16, 2026 at 3:46 am

    The problem is your pattern uses a dash in the middle, which acts as a range of the ascii characters from ) to =. Here’s a breakdown:

    • ): 41
    • 1: 49
    • =: 61

    As you can see, numbers start at 49, and falls between the range of 41-61, so they’re matched and replaced.

    You need to place the - at either the beginning or end of the character class for it to be matched literally rather than act as a range:

    "[-!@#$%^&*()=+`~{}'|]"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am removing all non-numeric and non-decimal values using: Regex.Replace(A1B2C3.D4E5F6.G7H8I9, @[^-?\d+\.], ); Output: 123.456.789
Okay, I have read about regex all day now, and still don't understand it
I am trying to come up with a regex for removing all words that
I have a text string that contain some references numbers like [3][2][4] or [1]
I am using a regex to replace all email addresses in a string with
I have a small Regex here where I am removing all the white spaces
I'm looking for a regex pattern that will look for an attribute within an
I need to scroll a List and removing all strings that contains some special
Any regex gurus around here? its driving me crazy. Say I have this string:
Simple regex question. I have a string on the following format: this is a

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.