begin process at 2010 03 12 18:19:07
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Texte

 > CONVERSIONS D'ADRESSES EN LIEN HTML

CONVERSIONS D'ADRESSES EN LIEN HTML


 Information sur la source

Note :
Aucune note
Catégorie :Texte Niveau :Débutant Date de création :30/07/2003 Date de mise à jour :31/07/2003 04:38:34 Vu :3 156

Auteur : Cyrille2

Ecrire un message privé
Site perso
Ce membre participe au partage de revenus publicitaires
Commentaire sur cette source (0)
Ajouter un commentaire et/ou une note


 Description

Bon ben, le texte veut tout dire, cette petite fonction permet de modifier une string par exemple 'cyrille2@free.fr http://www.visiomaster.net/' en '<a href="mailto:cyrille2@free.fr">cyrille2@free.fr </a> <a href="http://www.visiomaster.net/">http://www.v isiomaster.net/</a>". Pour l'appeler il suffit de faire

mastring := HandleProtocols(mastring,['http://','ftp://']); par exemple!  

Source

  • procedure ExplodeConcat(Source, Splitter : String; ConcatStart : Integer ; var SList : TStringDynArray);
  • var SplitPos : integer;
  • SLenght : Integer;
  • begin
  • SetLength(SList,1);
  • SLenght := 1;
  • SList[0] := Source;
  • repeat
  • SplitPos := posfull(Splitter,Source,True)-1;
  • Inc(SLenght);
  • SetLength(Slist,SLenght);
  • SList[SLenght-1] := Copy(Source,1,SplitPos);
  • Delete(Source,1,SplitPos+1);
  • until (Source = '') or (SLenght = ConcatStart);
  • if ConcatStart = SLenght Then
  • begin
  • SetLength(SList,ConcatStart+1);
  • SList[ConcatStart] := Source;
  • end
  • else
  • if ConcatStart > SLenght Then
  • begin
  • SetLength(SList,ConcatStart);
  • For SLenght := SLenght+1 to ConcatStart-1 Do
  • SList[SLenght] := '';
  • end;
  • end;
  • function HandleProtocols(Mess : String; protocols: array of string) : String;
  • var Strings : TStringDynArray;
  • I, J : integer;
  • Pos1 :integer;
  • begin
  • ExplodeConcat(Mess,' ',-1,Strings);
  • For I := 1 To length(Strings)-1 Do // mess complet
  • begin
  • Pos1 := pos('@',Strings[I]);
  • if not (Pos1 = 0) and not (PosFrom('.',strings[I],Pos1) = 0) Then
  • Strings[I] := '<a href="mailto:'+StringReplace(Strings[I],'"','',[rfReplaceAll])+'">'+Strings[I]+'</a>'
  • else
  • For J := 0 to Length(protocols)-1 Do
  • begin
  • Pos1 := Pos(protocols[J],Strings[I]);
  • if Pos1 = 1 Then
  • begin
  • Strings[I] := '<a href="'+StringReplace(Strings[I],'"','',[rfReplaceAll])+'">'+Strings[I]+'</a>';
  • Break;
  • end;
  • end;
  • Result := Result+' '+strings[I];
  • end;
  • SetLength(Strings,0);
  • end;
procedure ExplodeConcat(Source, Splitter : String; ConcatStart : Integer ; var SList : TStringDynArray);
var SplitPos : integer;
    SLenght : Integer;
begin
    SetLength(SList,1);
    SLenght := 1;

    SList[0] := Source;

    repeat
        SplitPos := posfull(Splitter,Source,True)-1;

        Inc(SLenght);
        SetLength(Slist,SLenght);

        SList[SLenght-1] := Copy(Source,1,SplitPos);
        Delete(Source,1,SplitPos+1);
    until (Source = '') or (SLenght = ConcatStart);

    if ConcatStart = SLenght Then
    begin
        SetLength(SList,ConcatStart+1);
        SList[ConcatStart] := Source;
    end
    else
        if ConcatStart > SLenght Then
        begin
            SetLength(SList,ConcatStart);

            For SLenght := SLenght+1 to ConcatStart-1 Do
                SList[SLenght] := '';
        end;
end;


function HandleProtocols(Mess : String; protocols: array of string) : String;
var Strings : TStringDynArray;
    I, J : integer;
    Pos1 :integer;
begin
    ExplodeConcat(Mess,' ',-1,Strings);

    For I := 1 To length(Strings)-1 Do // mess complet
    begin
        Pos1 := pos('@',Strings[I]);

        if not (Pos1 = 0) and not (PosFrom('.',strings[I],Pos1) = 0) Then
            Strings[I] := '<a href="mailto:'+StringReplace(Strings[I],'"','',[rfReplaceAll])+'">'+Strings[I]+'</a>'
        else
            For J := 0 to Length(protocols)-1 Do
            begin
                Pos1 := Pos(protocols[J],Strings[I]);

                if Pos1 = 1 Then
                begin
                    Strings[I] := '<a href="'+StringReplace(Strings[I],'"','',[rfReplaceAll])+'">'+Strings[I]+'</a>';
                    Break;
                end;
            end;

        Result := Result+' '+strings[I];
    end;

    SetLength(Strings,0);
end;  

 Conclusion

Bon conding ^^  


 Sources du même auteur

Source avec Zip Source avec une capture POP-UP KILLER VERSION 2.0 MULTIBROWSER MULTITHREAD
Source avec Zip Source avec une capture COMPO PUISSANCE 4
Source avec Zip TCONNEXIONTHREAD BASÉ SUR LE TCLIENTSOCKET EN MODE BLOQUANT
Source avec Zip COPIE DE FICHIER BYTE À BYTE VIA THREAD AVEC AVANCEMENT
Source avec Zip PETIT SERVER À BASE DE TSERVERSOCKET EN MULTITHREAD

 Sources de la même categorie

Source avec Zip COMBINAISONS DE STRINGS par askil2000
Source avec Zip Source avec une capture RECONNAISSANCE DE CARACTÈRES (OCR) par Bacterius
Source avec Zip Source avec une capture NETTOYAGE AUTOMATIQUE DE NOMS DE FICHIERS par John Dogget
DISTANCE DE JARO-WINKLER par PoulpHunter
Source avec Zip BASE DE DONNÉE WIKI par thithony

Commentaires et avis

Aucun commentaire pour le moment.

 Ajouter un commentaire




Nos sponsors


Appels d'offres

Sondage...

Comparez les prix

CalendriCode

Mars 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728
293031    

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,655 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales