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

The Archive Base Latest Questions

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

I know how to use Regex.Split() and Regex.Replace(); but not how to keep certain

  • 0

I know how to use Regex.Split() and Regex.Replace(); but not how to keep certain data when replacing.

if I had the following lines of text in a String[] (Split after every 😉

“

using system;
using system.blab;
using system.blab.blabity;

“

how would I loop trough and replace all ‘using’ to ” but match the whole line ‘using (.+;)’ for example.
and end up with the following (but not just Regex.replace(“using”, “”);)
“

<using> system;
<using> system.blab;
<using> system.blab.blabity;

“

  • 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:35:27+00:00Added an answer on June 16, 2026 at 3:35 am

    This should get you pretty close. You should use a named group for every logical item you’re trying to match. In this instance, you’re trying to match everything that is not the string “using”. You can then use the notation ${yourGroupName} to reference the match in the replacement string. I wrote a tool called RegexPixie that will show you live matching of your content as you type so you can see what works and what doesn’t work.

    //the named group has the name "everythingElse"
    var regex = new Regex(@"using(?<everythingElse>[^\r\n]+)");
    var content = new string [] { /* ... */ };
    
    for(int i = 0; i < content[i]; i++)
    {
         content[i] = regex.Replace(content[i], "${everythingElse}");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't know if I can use regex for this, but I want to
Ok I know everyone is going to tell me not to use RegEx for
I know and use the standard c# regex library, and I love it. It
I know you use the C based networking API to do FTP communication but
I know and use eric meyer CSS reset, but is there any more things
Now i know to use the method of float.Parse but have bumped into a
I would like to try Silex but i've some questions. I know to use
I don't know why I have to use Array.toString in the split(String reges) method.
I am not very good with regex (in fact don't know much at all).
I just want to know whether ruby regex has a not match operator just

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.