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. 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) 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) 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. 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 Link to comment https://forums.phpfreaks.com/topic/66309-solved-ereg-syntax/#findComment-331870 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.