Help for this page

Select Code to Download


  1. or download this
    substr $string, 0, 30; 
      # will extract UP TO the first 30 characters of the string.
    
    ...
    
    length($string) == 30;
      # tests if the string is 30 characters long.
    
  2. or download this
    my @strings = (
      join ('', 'a' .. 'z' ),
      join ('', 'a' .. 'z', 0 .. 3 ),
    ...
      print 'regex  : ', ( $string =~ m/.{30}/ ), "\n";
      print 'regex  : ', ( $string =~ m/(.{30})/ ), "\n";
    }
    
  3. or download this
    string : abcdefghijklmnopqrstuvwxyz
    length : 26
    substr : abcdefghijklmnopqrstuvwxyz
    ...
    substr : abcdefghijklmnopqrstuvwxyz0123
    regex  : 1
    regex  : abcdefghijklmnopqrstuvwxyz0123