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

  • SEARCH
  • Home
  • 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 6118079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:23:39+00:00 2026-05-23T15:23:39+00:00

I have a regular expression (regex) question… How would I use regular expressions to

  • 0

I have a regular expression (regex) question…

How would I use regular expressions to remove the contents in parenthesis in a string in C# like this:

“SOMETHING (#2)”

The part of the string I want to remove always appears within paranthesis and they are always # followed by some number. The rest of the string needs to be left alone.

  • 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-05-23T15:23:40+00:00Added an answer on May 23, 2026 at 3:23 pm

    Remove everything including the parenthesis

    var input = "SOMETHING (#2) ELSE";
    var pattern = @"\(#\d+\)";
    var replacement = "";
    
    var replacedString = System.Text.RegularExpressions.Regex.Replace(input, pattern, replacement);
    

    Remove only contents within parenthesis

    var input = "SOMETHING (#2) ELSE";
    var pattern = @"(.+?)\(#\d+\)(.+?)";
    var replacement = "$1()$2";
    
    var replacedString = System.Text.RegularExpressions.Regex.Replace(input, pattern, replacement);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im have a nice regular expression builder that looks like this: string numberOfDigits =
I have a regular expression like this (much simplified): ^(ab)*$ And am matching against
I'd like to build a regular expression assembly of common regex I must use
I have tried this... Dim myMatches As String() = System.Text.RegularExpressions.Regex.Split(postRow.Item(Post), \b\#\b) But it is
I have this regular expression: ^\$?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$ however it is failing when i have an
I have this Regular Expression that matches the following strings: <!-- 09-02-2009 ---> <!--
This may be a silly question but... Say you have a sentence like: The
Hey, first time poster on this awesome community. I have a regular expression in
I have got a question on regular expression. Though simple, I got some contracting
I have a quite general question about java and regular expression. If we lock

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.