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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:42:45+00:00 2026-06-03T09:42:45+00:00

Sample Input File +——————–+———+——— | Name | S1 | S2 +——————–+———+——— | A |

  • 0

Sample Input File

+--------------------+---------+---------
|           Name     |   S1    |    S2
+--------------------+---------+---------
|           A        | -4.703  | -2.378  
|           B        | -3283.2 | -3204.5 
|           C        |  8779   |  7302   
|           D        |  22078  |  18018  
+--------------------+---------+---------

It is required to remove the S1 Column, i.e

Desired Output

+--------------------+---------
|           Name     |   S2    
+--------------------+---------
|           A        | -2.378    
|           B        | -3205.5  
|           C        |  7302      
|           D        |  18018    
+--------------------+---------

Can anyone help with this

thanks

  • 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-03T09:42:47+00:00Added an answer on June 3, 2026 at 9:42 am

    In command mode:

    :%s/^\([[+|][^+|]\+\)[+|][^+|]\+/\1/
    

    This uses vim’s built-in sed-like search and replace command. Here’s the breakdown:

    % – for the entire file

    s – search for

    /^ – the start of line

    \([[+|][^+|]\+\) – followed by + or |, followed by any number (\+) of anything that is not + or |. This will get the first column, which we want to keep, so put it in a capture group by surrounding it with \( and \)

    [+|][^+|]\+ – followed by + or |, followed by any number (\+) of anything that is not + or |. This will get the second column, which we don’t want to keep, so no capture group.

    /\1/ – replace everything we matched with the first capture group (which contains the first column). This effectively replaces the first and second column with the contents of the first column.

    Like I said, vim’s regex are pretty much identical to sed, so you if you look through this tutorial on sed you’ll probably pick up a lot of useful stuff for vim as well.

    Edit

    In response to the OP’s request to make this more generally capable of deleting any column:

    :%s/^\(\([[+|][^+|]\+\)\{1\}\)[+|][^+|]\+/\1/
    

    The index inside of the \{\}, now deletes the column indicated. Think of it like an array index (i.e. starts at zero). So \{0\} now deletes the first column, \{1\} deletes the second, and so on.

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

Sidebar

Related Questions

I have this simple piece of HTML code: <div> <input type=file name=english-file /> </div>
My task is to create a parent-child hierarchy file using perl. Sample Input file
Here is a sample of my input file : $cat NDVI-bm P01 031.RAW 0.516
in input XML I have a tag <name>Sample '</name> in XSL I transform this
Is there a simple way to upload a single file through HTML input type
Sample input string: char *str = 12345.567675; And the desired output if I need
My sample input XML is: <root> <a> <b>item</b> <b>item1</b> <b>item2</b> <b>item3</b> <b>item4</b> </a> </root>
package pack; public class sample{ public static void main(String input[]) { NumberFormat numberFormat =
I followed these two exemples of developer.android (Creating an Input Method, Soft Keyboard sample).
I am trying to take an input file with @ARGV array and write it's

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.