Solved

preg_replace arguments to remove mailing list footer

Posted on 2003-11-24
5
275 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 500 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Checking https returns 301 21 54
How Close unsubmited attempts 10 42
Compiling PHP with Curl plus protocols 8 19
Get data from two MySQL tables 6 18
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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 …

685 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