oesi50: Anzahl unterschiedlicher Zeichen in einem String berechnen?

Beitrag lesen

Hallo Schnaps,

lies mal das:

perlfaq4 - Data Manipulation

If you want a count of a certain single character (X) within a string, you can use the tr/// function like so:

$string = "ThisXlineXhasXsomeXx'sXinXit";
    $count = ($string =~ tr/X//);
    print "There are $count X characters in the string";

Grüße Oesi