jake2891 Posted October 20, 2008 Share Posted October 20, 2008 Hi guys, Can anyone see why my preg_match equation is not matching? basically trying to work out how equations work in regular expressions <?php if(preg_match('/1\+2=3/',3)) { $this->test = "your paramater matches."; echo $test; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/129246-preg_match-help/ Share on other sites More sharing options...
The Little Guy Posted October 20, 2008 Share Posted October 20, 2008 if(preg_match('/(.+?)3(.+?)/','1+2=3')) { $this->test = "your paramater matches."; echo $test; } Quote Link to comment https://forums.phpfreaks.com/topic/129246-preg_match-help/#findComment-670054 Share on other sites More sharing options...
jake2891 Posted October 20, 2008 Author Share Posted October 20, 2008 thanks for your reply. Although im passing the value 3 via the url. So would there be another way of doing it mathematically besides the following way below? eg '/1\+2=3/' instead of '/3/' if(preg_match('/3/',$this->getRequest()->getParameter('test'))) // test holds the value 3 { $this->test = "your paramater matches."; echo $test; } Quote Link to comment https://forums.phpfreaks.com/topic/129246-preg_match-help/#findComment-670082 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.