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, 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) 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, 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)? Link to comment https://forums.phpfreaks.com/topic/177724-another-preg_match-question/#findComment-937141 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.