treeleaf20 Posted October 15, 2009 Share Posted October 15, 2009 All, I'm trying to find the following in a set of data: Content-Type: multipart/mixed; boundary= However, it gives me an error because of the / How can I get around this and include this in my search string? Quote Link to comment https://forums.phpfreaks.com/topic/177722-solved-preg_match-with-a/ Share on other sites More sharing options...
Alex Posted October 15, 2009 Share Posted October 15, 2009 Escape it with \ Quote Link to comment https://forums.phpfreaks.com/topic/177722-solved-preg_match-with-a/#findComment-937096 Share on other sites More sharing options...
treeleaf20 Posted October 15, 2009 Author Share Posted October 15, 2009 I tried: $pattern = '/Content-Type: multipart/mixed; boundary="(.*)\n|$/'; but it didn't work and I know it's in there. For example this is some sample data that I want to search for: From: User Name To: email@email.com Content-Type: multipart/mixed; boundary=00163631073750ac1b0475eaa507 X-Nonspam: None --00163631073750ac1b0475eaa507 Content-Type: multipart/alternative; boundary=00163631073750ac Quote Link to comment https://forums.phpfreaks.com/topic/177722-solved-preg_match-with-a/#findComment-937098 Share on other sites More sharing options...
treeleaf20 Posted October 15, 2009 Author Share Posted October 15, 2009 From that data I'm trying to find that and then pull: 00163631073750ac1b0475eaa50 Quote Link to comment https://forums.phpfreaks.com/topic/177722-solved-preg_match-with-a/#findComment-937099 Share on other sites More sharing options...
.josh Posted October 15, 2009 Share Posted October 15, 2009 Escape it with \ I tried: $pattern = '/Content-Type: multipart/mixed; boundary="(.*)\n|$/'; so...it looks like you still didn't escape it. Alternatively, you can use a different delimiter than / Quote Link to comment https://forums.phpfreaks.com/topic/177722-solved-preg_match-with-a/#findComment-937101 Share on other sites More sharing options...
treeleaf20 Posted October 15, 2009 Author Share Posted October 15, 2009 This is the whole code I use: $pattern = '/Content-Type: multipart\/mixed; boundary="(.*)\n|$/'; echo "The pattern is ".$pattern; $id_find = array(); if (preg_match($pattern, $data, $id_find)) { $id_look_up = $id_find[1]; print "<br><br>The id to look up is: $id_look_up"; // That should be the rest. } It echos the id to look up is but it doesn't echo the variable. Quote Link to comment https://forums.phpfreaks.com/topic/177722-solved-preg_match-with-a/#findComment-937103 Share on other sites More sharing options...
.josh Posted October 15, 2009 Share Posted October 15, 2009 you have a " in your $pattern that does not look like it's in your $data Quote Link to comment https://forums.phpfreaks.com/topic/177722-solved-preg_match-with-a/#findComment-937105 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.