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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:51:21+00:00 2026-05-24T12:51:21+00:00

I got problem with using split command. The input string is as follows: 080821_HWI-EAS301_0002_30ALBAAXX:1:8:1649:2027

  • 0

I got problem with using split command.
The input string is as follows:

080821_HWI-EAS301_0002_30ALBAAXX:1:8:1649:2027  83  chr10   42038185    255 36M =   42037995    -225    GCCAGGTTTAATAAATTATTTATAGAATACTGCATC    @?DDEAEFDAD@FBG@CDA?DBCDEECD@D?CBA>A    NM:i:0  MD:Z:36

I want to grab ‘2027’ from this string
my command is: line.split(':',4)[1].split()[0]
However, it doesn’t work. The output is ‘1’

Then I switch to line.split(':',4)
And output is still ‘1’, and I see the first-step split is already problematic.

However, when I try line.split(':',1), I got expected result as:

1:8:1649:2027   83  chr10   42038185    255 36M =   42037995-225    GCCAGGTTTAATAAATTATTTATAGAATACTGCATC    @?DDEAEFDAD@FBG@CDA?DBCDEECD@D?CBA>A    NM:i:0  MD:Z:36

I’m confused by this split command! (I asked the similar question before, and split command worked at that time)
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-05-24T12:51:21+00:00Added an answer on May 24, 2026 at 12:51 pm

    It appears that what you want is

    line.split(':',4)[4].split()[0]
    

    The numeric parameter to split indicates the maximum number of splits that will occur. So you have:

    >>> line='080821_HWI-EAS301_0002_30ALBAAXX:1:8:1649:2027 ...'
    >>> line.split(':',4)
    ['080821_HWI-EAS301_0002_30ALBAAXX', '1', '8', '1649', '2027 ...']
    

    If you pull element [1] out of this return value, you get ‘1’. I don’t see why you are surprised by this.

    Since you are allowing up to 4 splits, and the item you want will be the last one, the subscript you want is [4]:

    >>> line.split(':',4)[4]
    '2027 ...'
    

    Then you can split that on space and get element [0] from it to produce your result.

    You get the same result if you don’t pass a split limit value at all:

    >>> line.split(':')[4].split()[0]
    '2027'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a problem converting an object property to string while using reflection... string
I've got a little problem using WPF Dispatcher Timer. On each timer tick my
Got a problem with ComponentListener. I'm using it to check if a certain component
I've got a problem here with an MSI deployment that I'm working on (using
Currently I'm deal with a history message page using Cakephp.And I got a problem
So, I've got a problem using style=overflow:auto; on IE6 / 7 browsers. It just
I've got a strange problem with a try/catch block I'm using. I've got this
I have got a Client/Server Application that using Asynchronous Socket.My problem is i cant
I have a problem, I want split a text into sentence using fullstop (.)
I'm just adding ActiveAdmin to my app, I got a problem using show/edit/destroy action

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.