Solved

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

Posted on 2013-02-04
2
201 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

776 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