dsaba Posted December 27, 2007 Share Posted December 27, 2007 <?php $str = '" \\an//d " " \\an//d "'; echo "$str<br>"; $pat = '~(" )(\\an//d)( ")~e'; preg_match_all($pat, $str, $out); print_r($out); ?> outputs: " \an//d " " \an//d "<br> Array ( [0] => Array ( ) [1] => Array ( ) [2] => Array ( ) [3] => Array ( ) ) Why doesn't it match? (read it carefully) Link to comment https://forums.phpfreaks.com/topic/83357-solved-why-doesnt-this-simple-regex-match/ Share on other sites More sharing options...
dsaba Posted December 27, 2007 Author Share Posted December 27, 2007 ah here is why I changed this: $pat = '~(" )(\\an//d)( ")~e'; to this: $pat = '~(" )(\\\an//d)( ")~e'; you have to escape for the pattern itself, and then again for the string declaration solved Link to comment https://forums.phpfreaks.com/topic/83357-solved-why-doesnt-this-simple-regex-match/#findComment-424072 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.