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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:42:55+00:00 2026-05-27T06:42:55+00:00

I would to grab whatever text is between Nadal@gmail.com and This e-mail (and attachment(s))

  • 0

I would to grab whatever text is between “Nadal@gmail.com” and “This e-mail (and attachment(s)) is confidential, proprietary,” but dont know what is the best and most reliable way to do this. I thought regex but perhaps someone knows better. the number of empty lines may increase or decrease but those 2 strings will always have text between them. In this case the text is “testttinggg”

---------- Forwarded message ---------- From: person name Date: 2011/12/1 Subject: RE: this is a test subject To: Nadal@gmail.com

    testingggggg

    This e-mail (and attachment(s)) is confidential, proprietary,

I tried to write

       preg_match('/nadal@gmail\.com(.*?)This e-mail \(and attachment\(s\)\) is confidential,/', $wholeBody, $matches);     echo $matches[1];

but it didnt work..

  • 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-27T06:42:55+00:00Added an answer on May 27, 2026 at 6:42 am

    You’re on the right way with your regex. You have to remember that the dot . does not include linebreaks by default so you have to add the DOTALL modifier.

    You can try this. In capturegroup 1 you’ll have the content (without the empty whitespaces and linebreaks)

    (?<=Nadal@gmail.com)\s*(.*?)\s*(?=This e-mail \(and attachment\(s\)\) is confidential, proprietary,)
    

    You can see it in action here: http://regexr.com?2vc19

    Update:

    preg_match('/(?<=Nadal@gmail.com)\s*(.*?)\s*(?=This e-mail \(and attachment\(s\)\) is confidential, proprietary,)/s', $message, $matches);
    

    http://codepad.viper-7.com/C6Mxqd

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

Sidebar

Related Questions

I need to grab the base64-encoded representation of the ViewState . Obviously, this would
I'd like to write a code snippet that would grab all of the text
What would be the most effective way to grab the schema + table name
If i have a string containing three 0 values, how would i grab them
Is there an opposite of .find()? Where $('.myclass').except('#myid'); Would grab all elements with .myclass
In PHP, I had this line matches = preg_grep('/^for/', array_keys($hash)); What it would do
Firstly, this DB question could be a bit DB agnostic, but I am using
I know this isn't strictly a programming question but y'all must have experienced this.
I have a markup like this: <div class=classA classB>the content</div> What I would like
So I have written a query that will grab an order (this is for

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.