php - preg_match assistance needed -
hi need assistance changing preg_match check 2-16chars a-z 0-9 -_ , space. right checking url i'd need remove protocol, add space , 2-16 min/max chr.
public function checkurl($string) { if(empty($string) || preg_match("#^(http|https|ftp)://([a-z0-9][a-z0-9_-]*(?:.[a-z0-9][a-z0-9_-]*)+):?(d+)?/?#i", $string)) { return true; } else { if( isset($this) ) { $this->adderror("input error"); } return false; } }
i'm not sure part want change, but...
[need match] 2-16 chars a-z 0-9 -_ , space.
[\w- ]{2,16} \wmatchesa-z,a-z,0-9,_.-match literal-in character class outside of valid range.' 'match space (ignore quotes, stack overflow needed them display). match whitespace character, use\s.{2,16}quantify match between 2 , 16 times inclusively.- you change
(http|https|ftp)(?:https?|ftp), won't capture group, aren't using references.
Comments
Post a Comment