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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:12:09+00:00 2026-05-11T20:12:09+00:00

I have an html file where I’d like to get all the text inside

  • 0

I have an html file where I’d like to get all the text inside these two tags:

<div class="articleTitle">
</div> 

I’m not entirely sure how to do the php regex.
(I also know there are no html tags inside the div, so there’s no problem about nested tags)

update: when i try the solutions given i get this: Warning: preg_match() [function.preg-match]: Unknown modifier ‘d’ on line 29

  • 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-11T20:12:09+00:00Added an answer on May 11, 2026 at 8:12 pm
    preg_match('/<div class="articleTitle">(.*?)<\/div>/i', $source, $matches);
    print_r($matches);
    

    This is the “Explination” from RegexBuddy:

    <div class="articleTitle">(.*?)</div>
    
    Options: case insensitive
    
    Match the characters “<div class="articleTitle">” literally «<div class="articleTitle">»
    Match the regular expression below and capture its match into backreference number 1 «(.*?)»
       Match any single character that is not a line break character «.*?»
          Between zero and unlimited times, as few times as possible, expanding as needed (lazy) «*?»
    Match the characters “</div>” literally «</div>»
    
    Created with RegexBuddy
    

    (.*?) will capture everything between what comes before it until what comes after it, and it will be places into the $matches var.

    I assumed that the HTML will be in the $source var.

    I suggest that you look into RegexBuddy, it’s 39.95 (USD) but it is worth every penny. It can help build your RegExs with most every major RegEx implementation, and it can help you to learn RegEx

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

Sidebar

Related Questions

I have html-file. I have to replace all text between this: [%anytext%]. As I
I have an html file called snake.html that I would like to put inside
I have an html file that uses the span keyword in two different ways.
I have a html file that has invoice details I would like to know
I have a HTML file that is linked to a Java class using the
I have an HTML file (from Newegg) and their HTML is organized like below.
I have an HTML file that has a set of divs with the class
I have a HTML file like this (I only put the body of the
I have an html file that I'd like to open and read from, but
I have help.html file in resource directory. I can open it from Eclipse these

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.