WorldDrknss Posted August 23, 2007 Share Posted August 23, 2007 I am having trouble matching a string. String sent from a server: $Lock PROTOCOL Pk=NAME| Ereg: if(ereg("^\$Lock\s[*]\s\$Pk\=[*]\|$", $lock_cmd, $matches)){ echo("Good"); } else { echo("Not Correct"); } This will return "Not Correct" but if I remove "\" from the pipe then it will echo Good. I am trying to get it to match the pipe so it is not seen as an "OR" command. Quote Link to comment https://forums.phpfreaks.com/topic/66309-solved-ereg-syntax/ Share on other sites More sharing options...
WorldDrknss Posted August 23, 2007 Author Share Posted August 23, 2007 is this one somewhat closer: preg_match("#^\$Lock\s[^\s]\s\$Pk\=[^\|]\|#", $lock, $matches) Quote Link to comment https://forums.phpfreaks.com/topic/66309-solved-ereg-syntax/#findComment-331730 Share on other sites More sharing options...
MadTechie Posted August 23, 2007 Share Posted August 23, 2007 what about this preg_match("/\$Lock\s\w+\sPk=\w+\|/", $lock, $matches) Quote Link to comment https://forums.phpfreaks.com/topic/66309-solved-ereg-syntax/#findComment-331848 Share on other sites More sharing options...
WorldDrknss Posted August 23, 2007 Author Share Posted August 23, 2007 preg_match('/\A(\$Lock\s[^\s]*\sPk\=([^\|]*)\|)/', $hubCMD, $matches) is what I needed. Yours would work except the fact I needed to be able to match ascii and other characters. Quote Link to comment https://forums.phpfreaks.com/topic/66309-solved-ereg-syntax/#findComment-331863 Share on other sites More sharing options...
MadTechie Posted August 23, 2007 Share Posted August 23, 2007 Ahh ok, so you got it ? it helps to see a few matches and invalid matches.. if this is solved then please click topic solved Quote Link to comment https://forums.phpfreaks.com/topic/66309-solved-ereg-syntax/#findComment-331870 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.