A JM Posted October 15, 2009 Share Posted October 15, 2009 Just wanted to check if I was doing this correctly... I only want to allow alphanumeric, underscores and periods "." require 4 digit and a max of 20.. preg_match("/^\w\.{4,20}$/" Thanks, Quote Link to comment https://forums.phpfreaks.com/topic/177724-another-preg_match-question/ Share on other sites More sharing options...
.josh Posted October 15, 2009 Share Posted October 15, 2009 preg_match('~^[a-z0-9_.]{4,20}$~i',$subject) Quote Link to comment https://forums.phpfreaks.com/topic/177724-another-preg_match-question/#findComment-937107 Share on other sites More sharing options...
A JM Posted October 15, 2009 Author Share Posted October 15, 2009 Thanks for the reply and sorry for posting in the wrong forum.. A JM, Quote Link to comment https://forums.phpfreaks.com/topic/177724-another-preg_match-question/#findComment-937125 Share on other sites More sharing options...
.josh Posted October 15, 2009 Share Posted October 15, 2009 it happens. One thing I wasn't 100% clear on though. You said "require 4 digits" do you mean a minimum of 4 of any of those specified things (alphanumeric underscore or dot), or do you mean that out of 20 of those things, at least 4 of them have to be a digit as in a number (0-9)? Quote Link to comment https://forums.phpfreaks.com/topic/177724-another-preg_match-question/#findComment-937141 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.