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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:00:07+00:00 2026-05-25T06:00:07+00:00

Using Jsoup, what would be an optimal approach to extract text, of which its

  • 0

Using Jsoup, what would be an optimal approach to extract text, of which its pattern is known ([number]%%[number]) but resides in an HTML page that uses neither CSS nor divs, spans, classes or other identifying of any type (yup, old HTML page of which I have no control over)?

The only thing that consistently identifies that text segment (and is guaranteed to remain like that) is that is HTML always looks like this (within a larger body of HTML):

<hr>
2%%17
<hr>

(The number 2 and 17 are examples only. They could be any numbers and, in fact, these are the two variables that I need to reliably extract from that HTML page).

If that text were within an enclosing and uniquely identifying <span> or <div>, I would have no problem extracting it using Jsoup. The problem is that this isn’t the case and the only way I can think of right now (which is not elegant at all) is to process the raw HTML through a regex.

Processing the raw HTML through a regex seems inefficient however because I already have it parsed via Jsoup into a DOM.

Suggestions?

  • 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-25T06:00:07+00:00Added an answer on May 25, 2026 at 6:00 am

    How about this?

    Document document = Jsoup.connect(url).get();
    Elements hrs = document.select("hr");
    Pattern pattern = Pattern.compile("(\\d+%%\\d+)");
    
    for (Element hr : hrs) {
        String textAfterHr = hr.nextSibling().toString();
        Matcher matcher = pattern.matcher(textAfterHr);
    
        while (matcher.find()) {
            System.out.println(matcher.group(1)); // <-- There, your data.
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What would be an optimal way, using Jsoup, to extract all HTML (either to
I'd like to submit some text into this form using JSoup. How would I
I am currently using Jsoup to parse a html. The code is quite simple:
Im using JSoup to parse HTML response. I have multiple Div tags. I have
I'm trying to parse some html using jsoup (1.3.3) in my android activity. When
I am using Jsoup to extract URL of an webpage. The href attribute of
My app is using JSoup to download the HTML of a message board page
I am using jsoup to parse a number of things. I am trying to
I want to select all comments from a document using JSoup. I would like
Im using JSoup with android and so far I have been successful. In my

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.