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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:23:26+00:00 2026-06-07T21:23:26+00:00

I would need to get the text between certain strings with preg_match_all. I’ve tried

  • 0

I would need to get the text between certain strings with preg_match_all. I’ve tried using alternation, but I’m not getting the right info out. What I need is to get the randomtext between weekday-strings. From Friday it should go to the end of the text.

My data is as follows:

Monday 1.1.
randomtext
randomtext
Tuesday 2.1.
randomtext
randomtext
Wednesday 3.1
randomtext
randomtext
Thusday 4.1.
randomtext
randomtext
randomtext
Friday 5.1
randomtext
randomtext

What I have now is this, but it only captures the stuff after Monday, when it should stop to Tuesday and then do it again:

/(Monday|Tuesday|Wednesday|Thursday|Friday)([\s\S]+)/

Any ideas?

  • 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-07T21:23:28+00:00Added an answer on June 7, 2026 at 9:23 pm

    You can use preg_split().

    $day_pattern = '/([a-z]+?day [\d\.]+\n)/i';
    $bits = preg_split(
        $day_pattern,
        $str,
        null,
        PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE
    );
    if ($bits)
        foreach($bits as $bit)
            echo preg_match($day_pattern, $bit)
                ?
                '<h3>'.$bit.'</h3>'
                :
                '<p>'.$bit.'</p>';
    

    Outputs

    <h3>Monday 1.1.</h3>
    <p>randomtext
    randomtext</p>
    <h3>Tuesday 2.1.</h3>
    <p>randomtext
    randomtext</p>
    <h3>Wednesday 3.1</h3>
    <p>randomtext
    randomtext</p>
    <h3>Thusday 4.1.</h3>
    <p>randomtext
    randomtext
    randomtext</p>
    <h3>Friday 5.1</h3>
    <p>randomtext
    randomtext</p>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using PHP and preg_match_all I'm trying to get all the HTML content between the
I would need to get a Regular Expression, which matches all Unicode control characters
I would need little help here. I'm trying to get the git respository from
How would I get a value in between two the quotes after value=? So,
The problem: I need to extract strings that are between $ characters from a
I only really need the HBox answer but figure that if we get a
In ActionScript3 i wanted to get the text between 2 quotes from some HTML
I need to get real world date and time in Java. I use: Date
I would need to build a html table that has a horizontally scrollable column.
I would need a readonly / unmodifiable java.util.Stack . For List s there is

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.