Help for this page

Select Code to Download


  1. or download this
    my $string = "XXXX";
    my @count = split( "XX", $string );
    print $#count;   # Prints -1
    
  2. or download this
    my $string = "XXYY";
    my @count = split( /(.)\1/, $string, -1 );
    print $#count;   # Prints 4, not 2.