?
Solved

everything before a text block

Posted on 2013-02-04
2
Medium Priority
?
224 Views
Last Modified: 2013-02-05
want regex pattern to accept everything above

wrote: >


Will be there 1215 recipient wrote: >sender

want
Will be there 1215 recipient
0
Comment
Question by:rgb192
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 35

Accepted Solution

by:
Terry Woods earned 2000 total points
ID: 38853699
$body=' Will be there 1215 recipient wrote: >sender ';

$string = 'wrote: >';
$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:
 Will be there 1215 recipient

Open in new window

0
 

Author Closing Comment

by:rgb192
ID: 38858075
thanks,
can you help with adding many spaces/lines to the regex


http://www.experts-exchange.com/Programming/Languages/Regular_Expressions/Q_28021576.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

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‚Ķ
We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

752 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