fizix Posted December 22, 2006 Share Posted December 22, 2006 OK, all I want to do is match the string "%1" in regex. I've tried a million different ways but it's not working. Can anybody tell me how?Thanks! Quote Link to comment Share on other sites More sharing options...
obsidian Posted December 22, 2006 Share Posted December 22, 2006 Try this:[code]<?php$String = "My string contains %1";if (preg_match('|\%1|', $String)) { // String contains your match}?>[/code] Quote Link to comment Share on other sites More sharing options...
utexas_pjm Posted December 22, 2006 Share Posted December 22, 2006 If you're trying to match a string that is static, like "%1" it is more efficient to use a string matching function than regex (I'll save you the explanation unless you're curious) so the following code would (theoretically) accomplish the task in less time.[code]<?phpif (strpos($String, '%1') !== false){ // Match}?>[/code] Quote Link to comment Share on other sites More sharing options...
fizix Posted December 22, 2006 Author Share Posted December 22, 2006 Thanks! Quote Link to comment 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.