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

  • Home
  • SEARCH
  • 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 3974536
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:34:45+00:00 2026-05-20T04:34:45+00:00

Greetings everyone I have this regular expression which goes as follow: $thread_views_exp = ‘~<td

  • 0

Greetings everyone

I have this regular expression which goes as follow:

$thread_views_exp = '~<td class="alt1" align="center">.*</td> <td class="alt2" align="center">(.*)</td> </tr>~isU';

The purpose of this is to get all the ‘views’ ( first column from left ) for this sample thread url http://www.swalif.net/softs/swalif45. Everything works fine except for the first value.

Sample Output:

Array
(
    [0] => 12 528
    [1] => 2,732
    [2] => 506
    [3] => 73
    [4] => 83
    [5] => 245
    [6] => 100
    [7] => 201
    [8] => 55
    [9] => 55
    [10] => 37
    [11] => 349
    [12] => 123
    [13] => 75
    [14] => 173
    [15] => 260
    [16] => 101
    [17] => 660
    [18] => 158
    [19] => 66
    [20] => 177
    [21] => 165
    [22] => 228
    [23] => 812
    [24] => 347
    [25] => 197
    [26] => 348
    [27] => 263
    [28] => 176
    [29] => 315
    [30] => 173
    [31] => 273
    [32] => 199
)

Thanks for your assistance.
Imran

  • 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-20T04:34:46+00:00Added an answer on May 20, 2026 at 4:34 am

    It seems to be a case of table cell greedyness. My test also gave me an extraneous <td>. But there is a simple way to make the regex more stringent:

    $rx = '~<td class="alt1" align="center">.*</td> <td class="alt2" align="center">([\d,]+)</td> </tr>~isU';
    

    Here the \d+ used in place of .*? returns only exact matches. The previous .* was eating up too much.

    General tip: you might want to use [^<>]* for safely matching text content between html brackets, instead of .*. Maybe apply \s+ instead of just spaces.

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

Sidebar

Related Questions

Greetings, I have a particular object which can be constructed from a file, as
Greetings everyone. This is my first question here at stackoverflow so please bear with
Greetings everyone, going to need some help in clearing this exception. I get the
Greetings, SO. I have some code which I've made attempts at compiling using gcc,
Greetings, everyone. I'm trying to learn some Silverlight basics, and have decided to write
greetings all i have a domain class named car and i have an object
Greetings everyone, I'm having a very strange problem. I've created a DateTextBox which automaticly
Greetings everyone: I would love to get some information from a huge collection of
Greetings everyone. I'm in need of some experiance here as how to deal with
Greetings, everyone. I consider myself to be an intermediate developer, but, to be candid,

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.