Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

preg_replace arguments to remove mailing list footer

Posted on 2003-11-24
5
Medium Priority
?
281 Views
Last Modified: 2006-11-17
Hi All;

I need the expression to do a preg_replace on this:

--
MySQL General Mailing List


I need to remove it from the bottom of emails, I want to remove everything below this line from the email I am processing. 500 points because I want to take care of this tonite.
0
Comment
Question by:Squeebee
5 Comments
 
LVL 19

Expert Comment

by:Michael701
ID: 9815569
like this?

$pos = strpos ($mystring, "MySQL General Mailing List");
if ($pos)
{
  $mystring = substr($mystring, 0, $pos)
}
0
 
LVL 17

Author Comment

by:Squeebee
ID: 9815582
While I am sure that will work, I am trying to pass an argument to an existing app, and the existing app uses preg_replace. As such I need a preg_replace expression.
0
 
LVL 6

Accepted Solution

by:
andreif earned 2000 total points
ID: 9815890
$text = preg_replace('/MySQL General Mailing List/i','', $text)

I wonder if those "--" are part of the string? then try

$text = preg_replace('/\-\-[\n\r]+MySQL General Mailing List/is','', $text)
0
 
LVL 10

Expert Comment

by:NetGroove
ID: 9817106


$text = preg_replace('/MySQL General Mailing List[.\n\r]*/i','', $text);

0
 
LVL 17

Author Comment

by:Squeebee
ID: 9817710
Thanks andreif I will give that a try and get back to you.
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.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

926 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