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

The Archive Base Latest Questions

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

First off, I’m aware this is a bad practice and I have answered many

  • 0

First off, I’m aware this is a bad practice and I have answered many questions even saying so, but to clarify I am forced to use regex because this application stores regexes in a database and only functions this way. I absolutely cannot change the functionality

Now that we got that out of the way.. because I always use DOM methods I’m not used to doing this with regular expressions.

I want to capture everything inside of the intro content division, up to the first end div tag. I don’t care if the regex will fail on nested divs. I need to capture space ( newline ) characters too.

<div class="intro-content">
<p>blah</p>
<br/>
<strong>test</strong>
</div>

Regex so far:

<div\s*class="intro-content">(.*)</div>

This obviously doesn’t work because the . character will not match space characters.

I do realize there have been hundreds of question asked, but the questions I visited only had relatively simple answers ( excluding the DOM suggestion answers ) where a (.*) would not suffice because it doesn’t account for newlines, and some regexes were too greedy.

I’m not looking for a perfect, clean solution that will account for every possibility ( like that’s even possible ) – I just want a quick solution that will work for this solution so I can move on and work on more modern applications that aren’t so horribly coded.

  • 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-12T20:28:06+00:00Added an answer on May 12, 2026 at 8:28 pm

    It sounds like you need to enable the “dot all” (s) flag. This will make . match all characters including line breaks. For example:

    preg_match('/<div\s*class="intro-content">(.*)<\/div>/s', $html);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

first off this is a class assignment so i would appreciate help but just
First off, I will say i've spent 6 hours on this topic and have
First off, please accept my apologies if this question is basic, I mainly have
First off: Everything works , but I would like to fine tune this a
First off I have gone through this link http://codex.wordpress.org/Integrating_WordPress_with_Your_Website . I cannot use this.
First off I am completely new to Javascript but I have some HTML/CSS experience.
first off I'm a noob to PHP but here is my problem. I am
First off I use this code to make the navigation bar always stay fixed;
First off, I've never used GWT before. I have good experience in HTML/CSS/JS/JSP. I'm
First off tags wont work. I say this because i create 4 buttons all

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.