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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:13:10+00:00 2026-06-10T19:13:10+00:00

I have a webpage converted to a string and I’m trying to extract three

  • 0

I have a webpage converted to a string and I’m trying to extract three numbers from it from this line.

<td class="col_stat">1</td><td class="col_stat">0</td><td class="col_stat">1</td>

From the line above I already have it extracting the first ‘1’ using this

String filePattern = "<td class=\"col_stat\">(.+)</td>";
    pattern = Pattern.compile(filePattern);
    matcher = pattern.matcher(text);
    if(matcher.find()){
        String number = matcher.group(1);
        System.out.println(number);
    }       

Now what I want to do is extract the 0 and the last 1 but anytime I try edit the regular expression above it just outputs the complete webpage on the console. Anyone have any suggestions??
Thanks

  • 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-10T19:13:11+00:00Added an answer on June 10, 2026 at 7:13 pm

    Regex matching is greedy, try this instead (looking only for (\d+) instead of (.+) (which matches everything until the last </td>):

    String text = 
        "<td class=\"col_stat\">1</td>" + 
        "<td class=\"col_stat\">0</td>" + 
        "<td class=\"col_stat\">1</td>";
    String filePattern = "<td class=\"col_stat\">(\\d+)</td>";
    Pattern pattern = Pattern.compile(filePattern);
    Matcher matcher = pattern.matcher(text);
    while (matcher.find())
    {
        String number = matcher.group(1);
        System.out.println(number);
    }
    

    On a related note, I completely agree with other’s suggestions to use a more structured approach to interpreting HTML.

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

Sidebar

Related Questions

I have a webpage that accepts HTML-input from users. The input is converted into
I have a webpage including the following div: <div class='book_box'> <table border=0 cellspacing=0> <tr>
I have a webpage that redirects to another webpage like this: http://www.myOtherServer.com/Sponsor.php?RedirectPage=http://mylink.com/whereIwasgoingtogo.html Then the
I have a webpage that displays a very large list of data. Since this
I have the following string \u3048\u3075\u3057\u3093 . I got the string from a web
I'm trying to get familiar with Collections. I have a String which is my
in my Java code I have this snippet: String str = \\u9601; But I
I have a webpage that pulls information from a database, converts it to .csv
I have a class that looks like this: public class Foobar { private float
I am trying to figure out if in C# if I have converted a

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.