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? 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 \ 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 protected] Content-Type: multipart/mixed; boundary=00163631073750ac1b0475eaa507 X-Nonspam: None --00163631073750ac1b0475eaa507 Content-Type: multipart/alternative; boundary=00163631073750ac 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 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 / 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. 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 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
Archived
This topic is now archived and is closed to further replies.