• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

everything before a text block

want regex pattern to accept everything above

wrote: >


Will be there 1215 recipient wrote: >sender

want
Will be there 1215 recipient
0
rgb192
Asked:
rgb192
1 Solution
 
Terry WoodsIT GuruCommented:
$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
 
rgb192Author Commented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now