Solved

3D " pattern and " pattern

Posted on 2013-02-06
2
331 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

809 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