Destramic Posted April 18, 2011 Share Posted April 18, 2011 hey guys im not that good when it comes to regex...im after the syntax were a string(filename) will have .class.php inside please if anyone can help. examples: test.class.php, help.class.php ...etc thank Quote Link to comment Share on other sites More sharing options...
requinix Posted April 18, 2011 Share Posted April 18, 2011 Don't use regular expressions for this. It's too simple a problem. I assume you mean whether the string ends with ".class.php"? if (substr($string, -10) == ".class.php") { Quote Link to comment Share on other sites More sharing options...
Destramic Posted April 18, 2011 Author Share Posted April 18, 2011 ok but the file name could be the size of font_controller.class.php...that would work fine? Quote Link to comment Share on other sites More sharing options...
requinix Posted April 18, 2011 Share Posted April 18, 2011 Did you try running it? Quote Link to comment Share on other sites More sharing options...
Destramic Posted April 19, 2011 Author Share Posted April 19, 2011 that worked nicely...thanks alot Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted April 20, 2011 Share Posted April 20, 2011 or This will match more than what requinix posted if (preg_match("/\.class\.php$/i", $string)) { examples: code.class.PHP code.CLASS.php code.CLASS.PHP code.class.php Quote Link to comment 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.