Titre
Nombre de Mot(s) dans une chaine
Auteur
Source

cette fonction compte le nombre de mot(s) dans une chaine.

les chiffre sont compt� comme mots aussi

"j'adore" compte pour un mot et non deux


function NombreDeMots(Chaine :string):integer; var i :integer; c :char; DebutExist :Boolean; begin result := 0; DebutExist := false; for i := 1 to length(Chaine) do begin c := Chaine[i]; if c in ['''','a'..'z','A'..'Z','0'..'9'] then begin DebutExist := true; if i = length(chaine) then result := result + 1; end else begin if DebutExist then result := result + 1; DebutExist := false; end; end; end;

Site de l'auteur