using split() and regular expressions

Alin
June 30, 2008, 8:28 pm
using split() and regular expressions
Hi,
I am connecting to a pop3 account to retrieve email messages which are inserted in mysql.

In the email body, if the email is HTML, there is a line, like this one: Content-Type: text/html; charset=us-ascii.

I got stuck trying to use some regular expressions, to do a split() between that line, and the message coming right after. The regular expressions must be applyed after charset= (/[A-z0-9]/) as the charset can be different.

I also tryed $simething = eregi_replace("Content-Type: text/html; charset=^[a-z0-9]$", "", $var), but it's not working.
Is there any way to split that line from the message ?

Thanks!
Veselin
June 30, 2008, 9:41 pm
Re:
try something like this
/charset=([A-z0-9]+)/
does it only have digits and letters?
Alin
June 30, 2008, 10:26 pm
Re:
It has digits, letters and sometimes lines. (Like charset=UFT-8 or charset=iso-8852)
But it's no working, even if I add the line to the expression.

For example I have $text = "Content-Type: text/html; charset=us-ascii

Some text here";
And I tryed $message = explode("/charset=([A-z0-9]+)/", $text); to obtain the text in $message[1]
It's not working, even if I remove the middle line from us-ascii. I also tryed something with eregi_replace, to replace the full "Content-Type" line with "" or a space. But it's not working eighter.
Veselin
June 30, 2008, 11:43 pm
Re:
<?php
$text = 'Content-Type: text/html; charset=us-ascii';
preg_match("/charset=([A-z0-9-]+)/",$text,$matches);
echo $matches[1];
?>

this will show

us-ascii
Alin
July 1, 2008, 12:12 am
Re:
And if I use preg_match("/Content-Type: text/html; charset=([A-z0-9-]+)/",$mesaj,$matches); $matches[0]; will show Content-Type: text/html; charset=us-ascii, so I can do a split, to retrieve the text. Thanks! :)
Reply
Title:
Your name:
Your email: (email address will not be posted on the web site)
Reply:
Verification