HuggieBear Posted September 14, 2006 Share Posted September 14, 2006 According to the PHP manual, the following code should produce "Matched".[code]<?php$string = "sense and sensibility";if (preg_match("/(sens|respons)e and \1ibility/", $string)){ echo "Matched";}else { echo "No match made";}?>[/code]But it doesn't. It tells me, No match made. Anyone tell me if I'm missing something here? Have I overlooked something obvious. Can I only use back referencing in certain versions of PHP?RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/20794-php-manual-example/ Share on other sites More sharing options...
effigy Posted September 14, 2006 Share Posted September 14, 2006 Either change the double quotes surrounding your pattern to single quotes, or escape the backslash. Quote Link to comment https://forums.phpfreaks.com/topic/20794-php-manual-example/#findComment-92053 Share on other sites More sharing options...
HuggieBear Posted September 15, 2006 Author Share Posted September 15, 2006 Thanks effigy...I have another question, but I'll post it in a new topic with a new title.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/20794-php-manual-example/#findComment-92232 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.