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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:12:21+00:00 2026-06-15T20:12:21+00:00

*Note: The output of the Array() is a PHP print_r()* I have this HTML

  • 0

*Note: The output of the Array() is a PHP print_r()*

I have this HTML tag:

<tr>
    <td width="40" align="left"><div class="icSkill" id="skill4"></div></td>
    <td colspan="2">SOME_VALUE_I_WANT&nbsp;</td>
</tr>

I really want to extract this with RegEx and don’t want to use HTML parsers in this case.

I do this Regex (I use the s-flag to ignore the file’s newlines):

\<tr\>\<td\swidth="40"\salign="left"\>\<div\s+class="icSkill"\s+id="skill(\d+)".*\<\/tr\>

Problem now is that the Regex doesn’t stop at the first found close TR tag, but I want it to. I know it probably has something todo with assertions, only I don’t know how to.

Array
(
    [0] => <tr><td width="40" align="left"><div class="icSkill" id="skill4"></div></td><td colspan="2">SOME_VALUE_I_WANT&nbsp;
</td></tr><tr><td rowspan="2" align="left"><div class="icGuard" id="guard9"></div></td></tr>
    [1] => 4
)

The basic examples like: /[^<]*/ won’t work in this case. Is there also a way to tell regex something like:

/[^A_STRING]*/ (in words; stop unless you find A_STRING)
OR BETTER EXAMPLE:
/[^A_STRING_FIRST_TIME]*/ (in words; stop unless you find A_STRING for the FIRST_TIME)
  • 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-15T20:12:23+00:00Added an answer on June 15, 2026 at 8:12 pm

    The problem is greediness. .* consumes as much as it can. You can make it ungreedy by appending ?:

    ~<tr><td\s+width="40"\s+align="left"><div\s+class="icSkill"\s+id="skill(\d+)".*?</tr>~s
    

    Also, as you can see, there is really no need to do so much escaping. It only hinders legibility.

    An alternative way to make repetition ungreedy, is to use the modifier U, which makes all repetition ungreedy globally in the whole pattern. I prefer the local variant (using ?), though.

    In any case, there is a different possibility which mimics [^A_STRING]* (which doesn’t work, because it matches any string of characters, that do not include A, _, S, T, R, I, N or G). You can use a negative lookahead at every position of the repetition:

    (?:(?!A_STRING).)*
    

    (substitute this for .* or .*?). It should be equivalent in most cases, but execution time might differ. Plus, it’s a little harder to decipher.

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

Sidebar

Related Questions

NOTE: This is a followup to my question here. I have a program that
So i wanna do something like this in php. If i have a year
I have a string like this in my PHP code: $string = (A)[B]C/D/E:F?G; how
Can someone tell me why this alert is empty? var pending_dates = []; $.getJSON('/ajax/event-json-output.php',
So, basically, I've been writing this Game of Life PHP script. My output is
I have the following code in a PHP file called via Ajax (note -
I got this script to re size a picture and output it : <?php
I have an array in the below format. This array had around 100 elements
i have three arrays in php script $arr1=(a,b,c) //(1,2,3) $arr2=(d,e,f) //(4,5,6) $arr3=(g,h,i) //(7,8,9) note
Note: Boost's archive scheme is based on symmetrical input and output archive classes. It's

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.