I need help to extract "BODY" part from string according to the two following cases:
Case 1:
Var1 =
Content-Type: text/plain; charset="UTF-8"
BODY
--000000000000ddc1610580816add
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
BODY56 text/html
--000000000000ddc1610580816add-
Case 2:
Var1=
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
BODY
--000000000000ddc1610580816add--
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
BODY56 text/html
--000000000000ddc1610580816add-
I want to do:
if Var1 contains:
Content-Type: text/plain; charset="UTF-8"
then
extract text between
Content-Type: text/plain; charset="UTF-8"
and
--000000000000ddc1610580816add
else if Var1 contains:
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Then extract text between:
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
And --000000000000ddc1610580816add--.
my Code, I need to fix it if someone can fix it:
if (index($body, "Content-Type: text\/plain; charset=\"UTF-8\"\n
Content-Transfer-Encoding: quoted-printable") != -1) {
$body =~ /Content-Type: text\/plain; charset="UTF-8"\n
Content-Transfer-Encoding: quoted-printable(.*?)--00.*/s ;
$body=$1;
}
elsif (index($body, "Content-Type: text\/plain; charset=\"UTF-8\"") != -1)
{
$body =~ /Content-Type: text\/plain; charset="UTF-8"(.*?)--00.*/s ;
$body=$1;
}