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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:05:20+00:00 2026-06-18T05:05:20+00:00

I am working on a short assignment from school and for some reason, two

  • 0

I am working on a short assignment from school and for some reason, two delimiters right next to each other is causing an empty line to print. I would understand this if there was a space between them but there isn’t. Am I missing something simple? I would like each token to print one line at a time without printing the ~.

public class SplitExample
{
    public static void main(String[] args)
    {
        String asuURL = "www.public.asu.edu/~JohnSmith/CSE205";
        String[] words = new String[6];
        words = asuURL.split("[./~]");
        for(int i = 0; i < words.length; i++)
        {
            System.out.println(words[i]);
        }
    }
}//end SplitExample

Edit: Desired output below

www
public
asu
edu
JohnSmith
CSE205
  • 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-18T05:05:21+00:00Added an answer on June 18, 2026 at 5:05 am

    I would understand this if there was a space between them but there
    isn’t

    Yeah sure there is no space between them, but there is an empty string between them. In fact, you have empty string between each pair of character.

    That is why when your delimiter are next to each other, the split will get the empty string between them.

    I would like each token to print one line at a time without printing
    the ~.

    Then why have you included / in your delimiters? [./~] means match ., or /, or ~. Splitting on them will also not print the /.
    If you just want to split on ~., then just use them in character class – [.~]. But again, it’s not really clear, what output you want exactly. May be you can post an expected output for your current input.


    Seems like you are splitting on ., / and /~. In which case, you can’t use character class here. You can use this pattern to split: –

    String[] words = asuURL.split("[.]|/~?");
    

    This will split on: – ., /~ or / (Since ~ is optional)

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

Sidebar

Related Questions

I was working on a school assignment (doing Hoffman encoding) and I need some
So long story short, im working with some jquery tabs and im using this
I'm working on a school assignment and I'm having an issue with a 2d
I'm working on this for a school assignment http://cit.dixie.edu/cs/1410/asst_bulkrename.html . I just finished coding
I'm currently working on a programming assignment for school. It's a simple text-based RPG.
EDIT:This is from a working project of mine. Working. I declared some char arrays
I'm working on a short bash script to grab a JSON element from a
I am working on a short java assignment that I have been set. The
I've seen a number of posts on UIGetScreenImage, however, not a complete working (short)
I'm currently working on a small short-lived project. But despite the size it's complicated

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.