Solved

everything before a text block

Posted on 2013-02-04
2
215 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

708 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

19 Experts available now in Live!

Get 1:1 Help Now