find and remove chunk of a string, (more than replace())
Posted: Tue Jul 13, 2010 7:01 pm
Suppose I have this entire text contained in a single string variable:
[text]
--=_b6a990e35093cac7efaddd6539ff8b60
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=us-ascii;
charset=us-ascii
test1
test2
test3
[/text]
Some of you may recognize this as part of the body of MIME email, that's because it is! Anyways, I need a script which can check the Content-Type of this block of text. If the Content-Type is text/plain I need the script to then delete everything in the string up until test1.
Proceeding test1 should be \r\n\r\n so I can do a replace(substr(STRING, 0, strpos(STRING, '\r\n\r\n')), '') or some variation like that (there's probably a syntax error in there). I'm not sure how to do the first part of traversing the string and checking the Content-Type.
Any advice?
Thanks,
Shawn
[text]
--=_b6a990e35093cac7efaddd6539ff8b60
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=us-ascii;
charset=us-ascii
test1
test2
test3
[/text]
Some of you may recognize this as part of the body of MIME email, that's because it is! Anyways, I need a script which can check the Content-Type of this block of text. If the Content-Type is text/plain I need the script to then delete everything in the string up until test1.
Proceeding test1 should be \r\n\r\n so I can do a replace(substr(STRING, 0, strpos(STRING, '\r\n\r\n')), '') or some variation like that (there's probably a syntax error in there). I'm not sure how to do the first part of traversing the string and checking the Content-Type.
Any advice?
Thanks,
Shawn