elis Posted July 18, 2009 Share Posted July 18, 2009 I'm trying to figure this regex stuff out, so I've consulted a few resources how to properly write one -- but as my script is no longer working, I suspect I have it wrong. I'm trying to make sure a variable contains the correct allowed values which are alphanumeric and a single underscore followed by the word "useruid": i.e. W2kyK8Etr_useruid So I've written this: <?php $allow = "^[a-zA-Z0-9]_{1}useruid$"; if(eregi($allow,$_COOKIE[$genkey."_useruid"])) { $cleanuid = $_COOKIE[$genkey."_useruid"]; } ?> But it isn't working because I am new to this regex thing and probably messed something up. Could someone spot my mistake? Quote Link to comment https://forums.phpfreaks.com/topic/166453-solved-whats-wrong-with-my-expression/ Share on other sites More sharing options...
elis Posted July 18, 2009 Author Share Posted July 18, 2009 I figured it out. Quote Link to comment https://forums.phpfreaks.com/topic/166453-solved-whats-wrong-with-my-expression/#findComment-877765 Share on other sites More sharing options...
nrg_alpha Posted July 18, 2009 Share Posted July 18, 2009 If you are still using ereg, I would consider learning preg [part of pcre] instead, as ereg (part of POSIX) is depreciated as of php 5.3 and will no longer be included within the core as of version 6. Here are some additional resources to help get you started in pcre: http://www.regular-expressions.info/ http://weblogtoolscollection.com/regex/regex.php http://www.phpfreaks.com/forums/index.php/topic,127902.0.html http://www.phpfreaks.com/tutorial/regular-expressions-part1---basic-syntax These should be more than enough to help get you started. Quote Link to comment https://forums.phpfreaks.com/topic/166453-solved-whats-wrong-with-my-expression/#findComment-877770 Share on other sites More sharing options...
elis Posted July 20, 2009 Author Share Posted July 20, 2009 Thanks for the tip! Quote Link to comment https://forums.phpfreaks.com/topic/166453-solved-whats-wrong-with-my-expression/#findComment-878742 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.