Help for this page

Select Code to Download


  1. or download this
    # true if $string consists solely of allowed chars (and isn't empty)
    $string =~ m/^[\s\d-\(\)\.]+$/;
    
    # or, we could be true if $string contains anything except allowed cha
    +rs
    $string =~ m/[^\s\d-\(\)\.]/;
    
  2. or download this
    $string =~ m/^[\s\d-\(\)\.x]+|(?:[Ee]xt[\.]*)*$/;
    
  3. or download this
    sub is_valid {
        # check to see if an entry consists of valid "phone number" chars.
    ...
        # Ext or ext or x and digits.
        return ( $phone =~ m/^\d+(?:(?:[Ee]xt)|x)*\d$/ );
    }
    
  4. or download this
    unless ( is_valid($FORM{'phone'} ) {
        send_error("$FORM{'phone'} doesn't meet validity test");
        exit;
    }
    
  5. or download this
    $phone =~ m{^\d+[\d\-\.\s\(\)]+(?:(?:[Ee]xt[\.]*)|x)*\d$};
    
  6. or download this
    # valid number
    unless ($FORM{'phone'} =~ /^\d+[\s\d-\(\)\.]+$/) {
    ...
       # don't die if zero-length!
       die "Bad ext" if length($FORM{'ext'});
    }