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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:13:16+00:00 2026-06-08T17:13:16+00:00

I also want to take off the string after that till the next comma,

  • 0

I also want to take off the string after that till the next comma, and if that string is after “select” then I want to replace anything after select and till the next comma.
For example:
select a.column, a.myID, a.studentID from mytable

I have many textfiles like this so I need something that takes care of it like if I want to replace column with empty string it should look like after replace
select a.myID, a.studentID from mytable

and If I want to replace myID with empty string it should look like this after replace
select a.column, a.studentID from mytable

and If i want to replace studentID with empty string it should look like this
select a.column, a.myID from mytable.

Thanks
I’m working in C# I was thinking of using regex but can’t come up with a regex.

  • 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-08T17:13:17+00:00Added an answer on June 8, 2026 at 5:13 pm

    This is what you need >>

    using System;
    using System.Text.RegularExpressions;
    
    class Program
    {
      static void Main()
      {
        string input = "select ceiling(a.interest) as interest, a.myID as mID, a.studentID as sID from mytable";
        string column = "a.myID";
        string pattern = "((?<=\\bselect)\\s+[^,]*\\b" + Regex.Escape(column) + "\\b[^,]*\\s*,?|\\s*,\\s*[^,]*\\b" + Regex.Escape(column) + "\\b[^,]*(?=(?:,|\\sfrom\\b)))";
        string output = Regex.Replace(input, pattern, "", RegexOptions.IgnoreCase);
        Console.WriteLine(output);
      }
    }
    

    Test this code here.

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

Sidebar

Related Questions

I want to implement a String comparison function that doesn't take a different amount
I know it is quite subjective, but I also want to take this opportunity
I want to write a Shell (AWK, Sed also fine) program to take as
First off I want to be clear that I am not referring to simulcasting
I want to take the input from a standard, off the shelf, IP based
I am sure I can turn that error off somewhere! Take a look at
i want to save current date+time into database and also want to retrieve it.
I want to implement a function in the base class but I also want
I want to set the height of asp:panel to auto and I also want
i want to call a batch file from another batch file and also want

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.