SchweppesAle Posted September 30, 2009 Share Posted September 30, 2009 Hi, I have the following two strings $string[0] = " UA "WebZIP/4.0 (http://www.spidersoft.com)"; $string[1] = "192.168.1.1"; As you can see, they both possess REGEX meta characters. If I where to loop through the array and test a specific string against each of these; what sort of pattern would I use? example: $other_string = '.skdjlfsdUA "WebZIP/4.0 (http://www.spidersoft.com)lksjldfkjsdlkfj'; preg_match('/'.$string[0].'/', $other_string) /*returns Warning: preg_match() [function.preg-match]: Unknown modifier when in debug mode due to the . meta character within each of the IPs String[1] would also place additional regex meta characters within the pattern. I'm not really sure how to account for the additional characters within the string before running preg_replace*/ Quote Link to comment https://forums.phpfreaks.com/topic/176098-solved-finding-regex-meta-characters/ Share on other sites More sharing options...
cags Posted September 30, 2009 Share Posted September 30, 2009 Do you actually need to run Regex? It looks like you're just trying to check for a stristr or do a string compare? Quote Link to comment https://forums.phpfreaks.com/topic/176098-solved-finding-regex-meta-characters/#findComment-927911 Share on other sites More sharing options...
.josh Posted September 30, 2009 Share Posted September 30, 2009 preg_quote Quote Link to comment https://forums.phpfreaks.com/topic/176098-solved-finding-regex-meta-characters/#findComment-927919 Share on other sites More sharing options...
SchweppesAle Posted September 30, 2009 Author Share Posted September 30, 2009 preg_quote Man I love this forum. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/176098-solved-finding-regex-meta-characters/#findComment-927934 Share on other sites More sharing options...
.josh Posted September 30, 2009 Share Posted September 30, 2009 have to agree with cags though...if you're looking for an exact match, strstr or stristr or strpos or stripos would be better. Quote Link to comment https://forums.phpfreaks.com/topic/176098-solved-finding-regex-meta-characters/#findComment-927985 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.