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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:35:49+00:00 2026-05-27T02:35:49+00:00

I wrote a regex in Rad Soft to pull out a div tag from

  • 0

I wrote a regex in Rad Soft to pull out a div tag from some html. It tested well in the editor and php regex tester. Now I am trying to get it to implement with php on my current project but just doesn’t work. Usually its some simple solution that is failing to register since I have been staring at the problem too long.

here is the test sample being used

$temp = '<div>blah blah blah.
    You ordered these items: 
    <div id="product_list">

 - 1  Large -  Target
<span class="pricedisplay">R$ 1,00</span>
- 1  Large - Black
<span class="pricedisplay">R$ 1,00</span>
- 1  Large - Leather
<span class="pricedisplay">R$ 1,00</span>
- 1  Large - Preto
<span class="pricedisplay">R$ 1,00</span>

</div><span class="total-shipping"></span><span class="total-price">Total: <span class="pricedisplay">R$ 1,00</span>
</span></div>';

and for the regex:

<div\sid="product_list">([\s\w\d<=>/\\\$:",\.-]?)*[^(</div>)]</div>

which I tried using here:

$outputHTML = preg_replace_callback(preg_quote('<div\sid="product_list">([\s\w\d<=>/\\\$:",\.-]?)*[^(</div>)]</div>'), 'findProducts', $temp);

I have tried with/without the preg_quote. And if you know of any software similar to Rad that better simulates php’s regex, it would help alot. Thanks in advance!

  • 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-27T02:35:49+00:00Added an answer on May 27, 2026 at 2:35 am

    Regardless of whether this regex happened to work with some tester there are many mistakes in it.

    First :

    [\s\w\d<=>/\\\$:",\.-]
    

    Equals too :

    [\s\w\d<=>/$:",.\\-] 
    

    You need not unescape characters inside character class. Additionally you use preg_quote which escapes : . \ + * ? [ ^ ] $ ( ) { } = ! < > | : -

    Secondly :

    [^(</div>)]
    

    Means :

    "
    [^(</div>)]    # Match a single character NOT present in the list “(</div>)”
    "
    

    While what you probably wanted to write is :

    (?<!</div>)
    
    "
    (?<!         # Assert that it is impossible to match the regex below with the match ending at this position (negative lookbehind)
       </div>       # Match the characters “</div>” literally
    )
    "
    

    Lastly :

    ([\s\w\d<=>/\\\$:",\.-]?)* equals : [\s\w\d<=>/$:",.\\-]*

    Oh and yeah, what you are doing is potentially dangerous. You shouldn’t try to extract/parse html/xml/xhtml with regex when you have ready to use tools in your language.

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

Sidebar

Related Questions

I wrote a regex to fetch string from HTML, but it seems the multiline
I wrote a regex for finding id values of html elements: <.+ id\s*=\s*['](.+)['].*/?> For
I just wrote a regex for use with the php function preg_match that contains
I'm trying to write a regex that will parse out the directory and filename
I am trying to write a regex to get the numbers from strings like
Background: I've wrote a small library that is able to create asp.net controls from
I'm using some code to extract from a Google Url the keyword of the
I wrote the following line to parse images from twitter profiles and it works
I wrote this java method to do regex and missing something because it fails
I wrote a valitor class with a fair amount of regex in there. Using

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.