Solved

<div class=3D"gmail_quote">On Mon, Jan 2, 2012

Posted on 2013-02-04
2
208 Views
Last Modified: 2013-02-06
see related question for regex date format
http://www.experts-exchange.com/Programming/Languages/Regular_Expressions/Q_28019879.html

this is an html gmail body



what is the regex pattern for to accept everything before pattern

<div class=3D"gmail_quote">


$body='
Give me advance warning so I can ta=
ke the day off.<br><br><div class=3D"gmail_quote">On Mon, Jan 2, 2012 at 12=
:39 AM
';

Open in new window


want Give me advance warning so I can ta=ke the day off.<br><br>
0
Comment
Question by:rgb192
2 Comments
 
LVL 35

Accepted Solution

by:
Terry Woods earned 500 total points
ID: 38853694
$body='
Give me advance warning so I can ta=
ke the day off.<br><br><div class=3D"gmail_quote">On Mon, Jan 2, 2012 at 12=
:39 AM
';

$string = '<div class=3D"gmail_quote">';
$pattern = preg_quote($string, "#"); #escape special characters, and the # character for use as the delimiter
$new_body = preg_replace("#^(.*?){$pattern}.*#s", "$1", $body);

print $new_body;

Open in new window


Output:
Give me advance warning so I can ta=
ke the day off.<br><br>

Open in new window

0
 

Author Closing Comment

by:rgb192
ID: 38859406
thanks,
I have a related question
where there is
"
and
3D"

http://www.experts-exchange.com/Programming/Languages/Regular_Expressions/Q_28021982.html
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question