IrOnMaSk Posted July 11, 2011 Share Posted July 11, 2011 Hi guyz, so I'm using preg_match to find a certain phrase in a file. Here's the code $file = file_get_contents ('content.html', true);//get content from file for reading if (preg_match('/Application/',$file)) { email('email@me.com,$file); echo 'email sent'; } so the code above works fine. But how do I find word with the forward slash "/" in it? Is it even possible? Like: $file = file_get_contents ('content.html', true);//get content from file for reading if (preg_match('/Application/Software/',$file)) { email('email@me.com,$file); echo 'email sent'; } This will give me an error (Unknown Modifier 'S') Any Idea is appriciated!!! Thanks Quote Link to comment https://forums.phpfreaks.com/topic/241719-preg_match/ Share on other sites More sharing options...
AbraCadaver Posted July 11, 2011 Share Posted July 11, 2011 Use a different delimiter: if (preg_match('#Application/Software#',$file)) Or you can escape it: if (preg_match('/Application\/Software/',$file)) Quote Link to comment https://forums.phpfreaks.com/topic/241719-preg_match/#findComment-1241464 Share on other sites More sharing options...
IrOnMaSk Posted July 11, 2011 Author Share Posted July 11, 2011 thanks, Abra for the reply... It works perfectly... Quote Link to comment https://forums.phpfreaks.com/topic/241719-preg_match/#findComment-1241469 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.