Solved

3D " pattern and " pattern

Posted on 2013-02-06
2
321 Views
Last Modified: 2013-02-06
can you have this pattern work for both
<div class=3D"gmail_quote">
<div class="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
';


$body='
Give me advance warning so I can ta=
ke the day off.<br><br><div class="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

0
Comment
Question by:rgb192
2 Comments
 
LVL 35

Accepted Solution

by:
Terry Woods earned 500 total points
ID: 38861302
$pattern = '<div class=(3D)?"gmail_quote">';
$new_body = preg_replace("#^(.*?){$pattern}.*#s", "$1", $body);

print $new_body;

Open in new window


preg_quote can no longer be used since we don't want the special characters ( and ) and ? to be treated literally. There are no characters that need escaping in the pattern in this case.
0
 

Author Closing Comment

by:rgb192
ID: 38862214
thanks for code and explanation about the characters that do not need to be escaped
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
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 look for a specific file type in a local or remote server directory using PHP.

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now