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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:09:23+00:00 2026-05-29T10:09:23+00:00

I trying out using regEx to split a String which gives me an array

  • 0

I trying out using regEx to split a String which gives me an array with 2 items in it.
I am only really interested in the first element, however the debugger is reporting that it has nothing in(in yellow circle on screenshot) it but has a “value” of the item I matched in my Regex. (highlighted in blue on screenshot)

enter image description here

How do I programmatically get to the value?

Here is the code I am using:

//Handle Related description by stripping off data relating to it
        String[] descriptionShortened=jsonObject.getString("description").split("^.*[^Related]");
        String descriptionintro=descriptionShortened[0].toString();


        descriptionList.add(descriptionintro);
  • 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-29T10:09:23+00:00Added an answer on May 29, 2026 at 10:09 am

    [^Related] Matches a Character Class which matches everything except the letters R, e, l, a, t, e, d. Your regex will match anything and that’s why the first element of the array is empty. If you wanted to a string that has everything before the string “Related”, just call

    descriptionShortened = jsonObject.getString("description").split("Related");
    

    Everything before the string "Related" will be in the first element in the array that is returned. For instance, if jsonObject.getString("description") returns "abcdRelatedefgh", the code above would return an array { "abcd", "efgh" }.

    In regards to your first question and the screenshot, that String really is empty. The value is a pointer, but it’s pointing to empty space. Every String has a value field, but that doesn’t mean that it’s not empty.

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

Sidebar

Related Questions

I'm using ruby 1.9 and trying to find out which regex I need to
I'm trying to figure out how to implement my first RESTful interface using Django
I'm trying to exclude some data from a string using regex. var match =
I'm trying to work out how to extract POP3 headers using this regex ^(?[a-zA-Z-]+)(?(?=:).+)$
I'm trying to regex-out a hash given in a string from a web-service response.
Using c# regex I'm trying to match things in quotes which aren't also in
I am trying to remove from a string using Regex. I am receiving a
I'm trying to remove some words in a string using regex using below program.
I'm trying to split a string formatted like Bananas|,|Bananas|||Bananas|Oranges|,|Bananas|||Bananas|Oranges|||Bananas|Oranges|Green Apples|,|Bananas|||Bananas|Oranges|||Bananas|Oranges|Red Apples|,|Bananas|||Bananas|Oranges|||Bananas|Oranges|Pears with a regex,
I'm trying to figure out a problem I'm having with regex. I'm using this

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.