homer.favenir Posted May 16, 2008 Share Posted May 16, 2008 hi to all, i have a simple question. how can i ignore "\" from this string? \24 HOUR TELEPHONE ACCESS\ thanks Link to comment https://forums.phpfreaks.com/topic/105899-solved-24-hour-telephone-access-syntax-to-ignore-quotquot/ Share on other sites More sharing options...
thebadbad Posted May 16, 2008 Share Posted May 16, 2008 What do you mean by ignore? You can remove the slashes with str_replace(): <?php $str = str_replace('\\', '', $str); ?> Edit: Forgot to escape the backslash. Link to comment https://forums.phpfreaks.com/topic/105899-solved-24-hour-telephone-access-syntax-to-ignore-quotquot/#findComment-542692 Share on other sites More sharing options...
homer.favenir Posted May 16, 2008 Author Share Posted May 16, 2008 sorry i forgot to post my script my script is this if(preg_match("/[0-9]/", $strno)) if it see a digit it will accept the string, but when it sees a \24 HOUR TELEPHONE ACCESS\ it also accepts it, i dont need this string with "\" thanks Link to comment https://forums.phpfreaks.com/topic/105899-solved-24-hour-telephone-access-syntax-to-ignore-quotquot/#findComment-542695 Share on other sites More sharing options...
thebadbad Posted May 16, 2008 Share Posted May 16, 2008 You're not being very clear. What do you want to accept? Your code currently accepts a string containing a digit (i.e. the string can contain anything else too). Link to comment https://forums.phpfreaks.com/topic/105899-solved-24-hour-telephone-access-syntax-to-ignore-quotquot/#findComment-542700 Share on other sites More sharing options...
homer.favenir Posted May 16, 2008 Author Share Posted May 16, 2008 ok thanks for the reply my script is if(preg_match("/[0-9]/", $strno) && strpos($strno, "\\")! == false) and it return all string starting with "\" and i dont want that i want all string that isnt starting with "\" thanks! Link to comment https://forums.phpfreaks.com/topic/105899-solved-24-hour-telephone-access-syntax-to-ignore-quotquot/#findComment-542705 Share on other sites More sharing options...
thebadbad Posted May 16, 2008 Share Posted May 16, 2008 <?php if (preg_match("/[0-9]/", $strno) && strpos($strno, "\\") === false) ?> Will accept any string containing a digit (still don't get why you wanna do this check), not containing a backslash (anywhere). Link to comment https://forums.phpfreaks.com/topic/105899-solved-24-hour-telephone-access-syntax-to-ignore-quotquot/#findComment-542716 Share on other sites More sharing options...
homer.favenir Posted May 16, 2008 Author Share Posted May 16, 2008 in this script if (strpos($strno, "\\") === false) how can i ignore also "["? thanks Link to comment https://forums.phpfreaks.com/topic/105899-solved-24-hour-telephone-access-syntax-to-ignore-quotquot/#findComment-542739 Share on other sites More sharing options...
thebadbad Posted May 16, 2008 Share Posted May 16, 2008 <?php if (preg_match('/[0-9]/', $strno) && !preg_match('/[\[\\\\]/', $strno)) ?> Will accept any string containing a digit and not containing [ and \. Link to comment https://forums.phpfreaks.com/topic/105899-solved-24-hour-telephone-access-syntax-to-ignore-quotquot/#findComment-542779 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.