mysqldumper
-


Hinweise


Antwort
 
LinkBack Themen-Optionen Thema durchsuchen Thema bewerten
Alt 12.09.2007, 11:47   #1
TP-Veteran
 
Benutzerbild von Flow09
 
Registriert seit: Jun 2001
Ort: Wien
Flow09 ist auf einem guten Weg
Question

Email-/Internetadressen in links umwandeln


Hey,

ich suche eine PHP-Funktion die mir alle Email-/Internetadressen in einem Text in HTML-Links umwandelt.

Ich hab schon gegoogelt find aber bis jetzt leider nix passendes!

Könnt ihr mir bitte helfen!

Danke!
lg
Flow
__________________
Lesser known Programming Languages #13: SLOBOL
... Although many compilers allow you to take a coffee break while they compile, SLOBOL compilers allow you to travel to Bolivia to pick the coffee. Forty-three programmers are known to have died of boredom sitting at their terminals while waiting for a SLOBOL program to compile. Weary SLOBOL programmers often turn to a related (but infinitely faster) language, COCAINE.
Flow09 ist offline   Mit Zitat antworten


Alt 12.09.2007, 12:10   #2
TP-Moderator
 
Benutzerbild von Rizzo
 
Registriert seit: Aug 2004
Ort: Kaiserslautern
Rizzo lebt für das TP und seine UserRizzo lebt für das TP und seine UserRizzo lebt für das TP und seine UserRizzo lebt für das TP und seine UserRizzo lebt für das TP und seine UserRizzo lebt für das TP und seine UserRizzo lebt für das TP und seine UserRizzo lebt für das TP und seine UserRizzo lebt für das TP und seine User
Zitat:
Zitat von Flow09 Beitrag anzeigen
Ich hab schon gegoogelt find aber bis jetzt leider nix passendes!

Das wundert mich etwas, weil wir Dir in diesem Thread das schon mal anhand deiner "PLZ" erklärt haben. Fertige Suchmuster für Email- und Web-Adressen findest Du tonnenweise unter dem Link den ich in diesem Thread geposted habe. Das Ersetzen-Prozedere ist das selbe wie bei den PLZ, nur das Suchmuster ist ein anderes.
__________________
#.Viele Grüße, Andreas
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
.
Rizzo ist offline   Mit Zitat antworten
Alt 12.09.2007, 12:22   #3
TP-Veteran
 
Benutzerbild von Flow09
 
Registriert seit: Jun 2001
Ort: Wien
Flow09 ist auf einem guten Weg
Ja, auf php.net bin ich inzwischen auch schon auf brauchbares gestoßen!!

Genauer gesagt auf diese Funktion:
PHP-Code:
function replaceLink($text) {
    
    
$text ereg_replace('[-a-z0-9!#$%&\'*+/=?^_`{|}~]+@([.]?[a-zA-Z0-9_/-])*','<a href="/newmessage/\\0/">\\0</a>',$text);
    
    
$text ereg_replace('[a-zA-Z]+://(([.]?[a-zA-Z0-9_/-])*)','<a target="_blank" href="\\0">\\1</a>',$text);
    
    
$text ereg_replace('(^| )(www([-]*[.]?[a-zA-Z0-9_/-?&%])*)',' <a target="_blank" href="http://\\2">\\2</a>',$text);
    
    return 
$text;
        

Hierbei hab ich allerdings noch ein Problem wenn ich einen Text mit mehreren Links übergebe wird nur der erste Link umgewandelt und der Rest nicht mehr.

ereg_replace dürfte nach dem ersten match aufhören!?!?!
__________________
Lesser known Programming Languages #13: SLOBOL
... Although many compilers allow you to take a coffee break while they compile, SLOBOL compilers allow you to travel to Bolivia to pick the coffee. Forty-three programmers are known to have died of boredom sitting at their terminals while waiting for a SLOBOL program to compile. Weary SLOBOL programmers often turn to a related (but infinitely faster) language, COCAINE.
Flow09 ist offline   Mit Zitat antworten
Alt 17.09.2007, 10:43   #4
TP-Veteran
 
Benutzerbild von Flow09
 
Registriert seit: Jun 2001
Ort: Wien
Flow09 ist auf einem guten Weg
Also, wie schon gesagt, die Funktion die ich gefunden habe ist schön und gut! Allerdings hat sie einige Fehler:

1.) Bei Texten mit mehreren Links wird nur der erste Link umgewandelt und der Rest nicht!

2.) Bei Links mit GET Argumenten (wie z.B von youTube http://www.youtube.com/watch?v=lQNDHY6hu_o) funkt das auch nicht.

Kann mir bitte einer weiterhelfen, ich hab von reg exps ziemlich wenig Ahnung!

lg
Flow
__________________
Lesser known Programming Languages #13: SLOBOL
... Although many compilers allow you to take a coffee break while they compile, SLOBOL compilers allow you to travel to Bolivia to pick the coffee. Forty-three programmers are known to have died of boredom sitting at their terminals while waiting for a SLOBOL program to compile. Weary SLOBOL programmers often turn to a related (but infinitely faster) language, COCAINE.
Flow09 ist offline   Mit Zitat antworten
Alt 23.10.2007, 11:07   #5
TP-Veteran
 
Benutzerbild von Flow09
 
Registriert seit: Jun 2001
Ort: Wien
Flow09 ist auf einem guten Weg
So, inzwischen hab ich die Lösung gefunden:

PHP-Code:
$text eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)',
                
'<a href="\1" target=_blank>\1</a>'$text);

        
$text eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)',
        
'\1<a href="http://\2" target=_blank>\2</a>'$text); 
Mir fehlt jetzt nur noch ein kleines Stück! Ich möchte alle Links nur mit der Domain anzeigen: Sprich der Link http://www.domin.com/var?x=blablabla soll nur als "www.domain.com" angezeigt werden.

Ich bekomm das aber nicht hin, ich brauche bitte eure Hilfe!!

lg
Flow
__________________
Lesser known Programming Languages #13: SLOBOL
... Although many compilers allow you to take a coffee break while they compile, SLOBOL compilers allow you to travel to Bolivia to pick the coffee. Forty-three programmers are known to have died of boredom sitting at their terminals while waiting for a SLOBOL program to compile. Weary SLOBOL programmers often turn to a related (but infinitely faster) language, COCAINE.
Flow09 ist offline   Mit Zitat antworten
Alt 23.10.2007, 11:18   #6
TP-Moderator
 
Benutzerbild von Rizzo
 
Registriert seit: Aug 2004
Ort: Kaiserslautern
Rizzo lebt für das TP und seine UserRizzo lebt für das TP und seine UserRizzo lebt für das TP und seine UserRizzo lebt für das TP und seine UserRizzo lebt für das TP und seine UserRizzo lebt für das TP und seine UserRizzo lebt für das TP und seine UserRizzo lebt für das TP und seine UserRizzo lebt für das TP und seine User
Zitat:
Zitat von Flow09 Beitrag anzeigen
Mir fehlt jetzt nur noch ein kleines Stück! Ich möchte alle Links nur mit der Domain anzeigen: Sprich der Link http://www.domin.com/var?x=blablabla soll nur als "www.domain.com" angezeigt werden.
Mal diese quick & dirty Lösung als Ansatz
PHP-Code:
<?php
$url 
"http://www.domin.com/var?x=blablabla";
preg_match"#http://(.*)/(.*)#"$url$treffer );
echo 
$treffer[1];
?>
__________________
#.Viele Grüße, Andreas
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
.
Rizzo ist offline   Mit Zitat antworten
Alt 23.10.2007, 11:33   #7
TP-Veteran
 
Benutzerbild von Flow09
 
Registriert seit: Jun 2001
Ort: Wien
Flow09 ist auf einem guten Weg
Danke für die Hilfe, aber das is nicht so ganz was ich Suche. Das ganze sollte in den schon vorhandenen Code eingebaut werden.
Ausserdem sollte es bei all diesen Fällen hier funktionieren:

http://www.domain.com/asdjkfhas
http://www.domain.com
http://domain.com
http://domain.com/jnsjlhsxcj
www.domain.com
www.domain.com/haskjdhasjkhdk

Aber trotzdem danke, vielleicht fällt mir da ja noch was ein!

lg
Flow
__________________
Lesser known Programming Languages #13: SLOBOL
... Although many compilers allow you to take a coffee break while they compile, SLOBOL compilers allow you to travel to Bolivia to pick the coffee. Forty-three programmers are known to have died of boredom sitting at their terminals while waiting for a SLOBOL program to compile. Weary SLOBOL programmers often turn to a related (but infinitely faster) language, COCAINE.
Flow09 ist offline   Mit Zitat antworten
Alt 23.10.2007, 11:38   #8
TP-Moderator
 
Benutzerbild von Rizzo
 
Registriert seit: Aug 2004
Ort: Kaiserslautern
Rizzo lebt für das TP und seine UserRizzo lebt für das TP und seine UserRizzo lebt für das TP und seine UserRizzo lebt für das TP und seine UserRizzo lebt für das TP und seine UserRizzo lebt für das TP und seine UserRizzo lebt für das TP und seine UserRizzo lebt für das TP und seine UserRizzo lebt für das TP und seine User
Deswegen sagte ich ja auch "Ansatz"!
Kombiniere eben mal dein funktionierendes Suchmuster mit dem von mir geposteten preg_match und schon hast Du was funktionierendes. Mein Schnipsel sollte Dir lediglich zeigen wie man an das ausgefilterte Ergebnis kommt, mehr nicht!

EDIT
BTW, wenn die URL bereits vorliegt könntest Du es dir auch leicht machen und parse_url benutzen.
__________________
#.Viele Grüße, Andreas
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
.
Rizzo ist offline   Mit Zitat antworten
Alt 24.10.2007, 22:52   #9
TP-Specialist
 
Benutzerbild von MichaelM
 
Registriert seit: Jan 2004
Ort: Münster-Hiltrup
MichaelM hilft, wo's gehtMichaelM hilft, wo's gehtMichaelM hilft, wo's geht
Also, ich mache es beim auslesen von Emailadressen so aus einer Datenbank zum Beispiel so:
Natürlich geht das auch mit Urls
PHP-Code:
<a href="mailto:<?PHP echo $email."?subject=Antwort an $kontaktvorname $kontaktnachname aus Tourenanfrage vom $kontakteintragsdatum  $kontaktinfo.";?>" class="linkweiss2"><?PHP echo $email;?></a>
__________________
Harleylujar, Michael!!

Falls mein Beitrag zu einer Lösung geführt hat,
würde ich mich über eine konstruktive Bewertung freuen.


Man sieht nur mit dem Herzen gut - das Wesentliche ist für das Auge unsichtbar...


www.mikel-mueller.de
www.sanitaertechnik-mueller.de

-------------------------------------
Mein Useralbum

Geändert von MichaelM (24.10.2007 um 22:58 Uhr).
MichaelM ist offline   Mit Zitat antworten
Alt 30.10.2007, 18:43   #10
TP-Veteran
 
Benutzerbild von Flow09
 
Registriert seit: Jun 2001
Ort: Wien
Flow09 ist auf einem guten Weg
So!

Jetzt hab ich mir mal das hier zusammegestückelt!

PHP-Code:
preg_replace("#(^|[\n ])(([\w]+?://[\w\#$%&~.\-;:=,?@\[\]+]*)(/[\w\#$%&~/.\-;:=,?@\[\]+]*))#si""\\1<a href=\"\\2\" target=\"_blank\">\\3</a>"$ret); 
Bis auf eine Kleinigkeit erledigt das auch seine arbeit sehr gut. Folgendes Problem hab ich nur noch, das regex funkt bei url strings wie http://www.domain.com/blabla und http://www.domain.com/

Leider kommt es bei http://www.domain.com (also ohne / am Ende) zu Problemen. Der String wird nicht gefunden ohne ein Slash am Ende. Ich hab jetzt schon einiges ausprobiert, finde die Lösung aber nicht. Ich brauche also bitte nochmal eure Hilfe.

lg
Flow
__________________
Lesser known Programming Languages #13: SLOBOL
... Although many compilers allow you to take a coffee break while they compile, SLOBOL compilers allow you to travel to Bolivia to pick the coffee. Forty-three programmers are known to have died of boredom sitting at their terminals while waiting for a SLOBOL program to compile. Weary SLOBOL programmers often turn to a related (but infinitely faster) language, COCAINE.
Flow09 ist offline   Mit Zitat antworten
Alt 31.10.2007, 10:07   #11
TP-Veteran
 
Benutzerbild von Flow09
 
Registriert seit: Jun 2001
Ort: Wien
Flow09 ist auf einem guten Weg
Hab die Lösung:

PHP-Code:
preg_replace("#(^|[\n ])(([\w]+?://[\w\#$%&~.\-;:=,?@\[\]+]*)(/[\w\#$%&~/.\-;:=,?@\[\]+]*)?)#is""\\1<a href=\"\\2\" target=\"_blank\">\\3</a>"$text);
preg_replace("#(^|[\n ])(((www|ftp)\.[\w\#$%&~.\-;:=,?@\[\]+]*)(/[\w\#$%&~/.\-;:=,?@\[\]+]*)?)#is""\\1<a href=\"http://\\2\" target=\"_blank\">\\3</a>"$text); 
__________________
Lesser known Programming Languages #13: SLOBOL
... Although many compilers allow you to take a coffee break while they compile, SLOBOL compilers allow you to travel to Bolivia to pick the coffee. Forty-three programmers are known to have died of boredom sitting at their terminals while waiting for a SLOBOL program to compile. Weary SLOBOL programmers often turn to a related (but infinitely faster) language, COCAINE.
Flow09 ist offline   Mit Zitat antworten
Antwort

  Aktuelles Thema
  TP Hilfe Forum > Web-Editoren & Coding > Traum-Dynamik
Email-/Internetadressen in links umwandeln Email-/Internetadressen in links umwandeln
« Gallerie mit Lightbox 2 | Frame "ausklappbar"? »

Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
 
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Thema bewerten
Thema bewerten:

Forumregeln
Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are an
Gehe zu


Alle Zeitangaben in WEZ +2. Es ist jetzt 20:19 Uhr.

Powered by: vBulletin Version 3.7 (Deutsch)
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd. / Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.
Traum-Projekt.com | Suchen | Archiv | Impressum | Kontakt | | | Nach oben |



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67