• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 240
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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