Solved

3D " pattern and " pattern

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

Technology Partners: 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

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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 dynamically set the form action using jQuery.

726 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