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

The Archive Base Latest Questions

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

I am having a brain freeze – I am running the following (split on

  • 0

I am having a brain freeze – I am running the following (split on string in java – trying to separate the characters around “|”). The split command is giving me an array of individual characters instead of the the values around the ‘|’ character. Any helpful suggestions would be most welcome. For instance, in the case below, I am trying to retrieve “abc”, “123456789” and “def” in three different array locations.

//testKey is the following "abc|123456789|def"
String[] keySplit = testKey.split("|");
//I am getting null in keySplit[0] & "a" in keySplit[1]
  • 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:52:32+00:00Added an answer on June 18, 2026 at 5:52 am

    String#split uses a regular expression. Also, the pipe operator| is a special character in regular expressions (meaning OR). Therefore, you need to escape that character here:

    String[] keySplit = testKey.split("\\|");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having a major brain freeze, I have the following chunk of code: // Get
I'm having a brain fart trying to make the following method more generic such
Having a brain freeze over a fairly trivial problem. If I start with an
ok, I must be having a brain freeze here... I have a ComboBox with
I'm currently having an issue wrapping my brain around the notion of converting my
I'm very new to Sql, and having trouble wrapping my brain around the syntax.
I'm new to jquery and, in addition, I think I'm having a brain freeze.
I'm having a bit of a brain-freeze so I thought I'd throw this out
I'm having a brain cramp trying to understand the appropriate way to use JGoodies
I'm having trouble wrapping my brain around something. If I open a URL manually

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.