Solved

everything before a text block

Posted on 2013-02-04
2
219 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
2 Comments
 
LVL 35

Accepted Solution

by:
Terry Woods earned 500 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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 count occurrences of each item in an array.

770 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