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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:59:14+00:00 2026-06-17T16:59:14+00:00

System.out.println(neon.mems.cmu.edu/people/.split(/).length); // output is 2 I was doing some url processing. To my surprise

  • 0
System.out.println("neon.mems.cmu.edu/people/".split("/").length); // output is 2

I was doing some url processing. To my surprise I just got the result above. I thought the number of elements could be the number of splitters plus one.

I didn’t realize the last empty string(or just null) is cut off from the splitted array until now. I wonder if this is the case with every programming language.

  • 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-17T16:59:15+00:00Added an answer on June 17, 2026 at 4:59 pm

    No that’s not the case for every programming language and there is no universal specification so there is no reason it should be.

    Go

    a := strings.Split("neon.mems.cmu.edu/people/", "/")
    fmt.Println(len(a)) // prints 3
    

    Javascript

    Type this in the console of your browser :

    "neon.mems.cmu.edu/people/".split('/')
    

    The result is

    ["neon.mems.cmu.edu", "people", ""]
    

    What you should do when a match is empty isn’t something obvious or inherent to the split concept. A proof of that is that old Internet Explorer versions did remove those empty matches.

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

Sidebar

Related Questions

System.out.println(1+2+3); System.out.println(1+2+3); output:- 33 123 First case is understood but the second case is
System.out.println( Arrays.deepToString( abc<def>ghi.split((?:<)|(?:>)) ) ); This prints [abc, def, ghi] , as if I
When I do System.out.println(map) in Java, I get a nice output in stdout. How
In Java I run: System.out.println(Math.log(249.0/251.0)); Output: -0.008000042667076265 In C# I run: <- fixed Math.Log
I've got this statement in Java: System.out.println(3|4); Why is the output 7?
public void processing() { System.out.println(Please enter the amount of saving per month: ); try
Consider the simple example: System.out.println(¬); System.out.println((int)(('¬'))); System.out.println((char)170); The output I get is as follows
If you execute: System.out.println(someObj.toString()); you probably see the output like someObjectClassname@hashcodenumber My question :
System.out.println(4 | 3); The output is 7. It does addition up to 3 numbers,
I have some libraries that are calling System.out.println on me, I'd like to redirect

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.