Stránka: 1 z 1
| [ Príspevkov: 6 ] | |
Autor | Správa |
---|
Registrovaný: 09.09.07 Prihlásený: 07.11.16 Príspevky: 3114 Témy: 233 | 233 Bydlisko: Nové Zámky |
Zdar,
nemate niekto nejaky dobry regulerny vyraz pre sklikatelnenie adresy v texte?? Mne sa podarilo zostavit len taky, ktory bere do uvahy ten odkaz len vtedy, ak je prednim a zanim medzera.. Ale chcem tak, aby za nim mohlo byt zariadkovane, alebo aby mohol byt na samostatnom riadku..
teraz mam nieco taketo:
Kód: $input = preg_replace("# http(s)?://([^, ]+) #"," <a href=\"http://$2\" target=\"_blank\">$2</a>", $input); $input = preg_replace("# www.([^, ]+) #"," <a href=\"http://$1\" target=\"_blank\">$1</a>", $input);
Ale nie je to to prave orechove
_________________ "It took a lot of work, but this latest Linux patch enables support for machines with 4096 CPUs, up from the old limit of 1024." "Do you have support for smooth full-screen flash video yet?" "No, but who uses that?"
- ak dlho neodpisujem do témy, zabudol som na ňu, takže ma upozornite SS, ak chcete moju odpoveď |
|
Registrovaný: 26.12.06 Prihlásený: 16.11.19 Príspevky: 3971 Témy: 181 | 181 Bydlisko: Nitra / Bra... | |
Registrovaný: 11.08.07 Príspevky: 4088 Témy: 34 | 34 Bydlisko: Brno |
Miesto medzery daj \s, to znamena medzeru, tabulator aj novy riadok.
|
|
Registrovaný: 09.09.07 Prihlásený: 07.11.16 Príspevky: 3114 Témy: 233 | 233 Bydlisko: Nové Zámky |
a ako konkretne mam toto pouzit?
Kód: (http|https|ftp)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)?((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.[a-zA-Z]{2,4})(\:[0-9]+)?(/[^/][a-zA-Z0-9\.\,\?\'\\/\+&%\$#\=~_\-@]*)*
Tieto regulerne vyrazy su moja nocna mora
preg_replace("sem to dam","a tu?",$p)
_________________ "It took a lot of work, but this latest Linux patch enables support for machines with 4096 CPUs, up from the old limit of 1024." "Do you have support for smooth full-screen flash video yet?" "No, but who uses that?"
- ak dlho neodpisujem do témy, zabudol som na ňu, takže ma upozornite SS, ak chcete moju odpoveď |
|
Registrovaný: 30.05.06 Prihlásený: 08.10.14 Príspevky: 1756 Témy: 35 | 35 Bydlisko: BA - WESTSIDE |
Skús takto: Kód: $pattern = "/(http|https|ftp)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)?((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.[a-zA-Z]{2,4})(\:[0-9]+)?(/[^/][a-zA-Z0-9\.\,\?\'\\/\+&%\$#\=~_\-@]*)*)"; $replace = "<a href='$0'>$0</a>"; $text = "bla bla bla odkaz bla bla bla"; $replaced = preg_replace($pattern, $replace, $text); Len neviem, či je ten regexp úplne najvhodnejší... EDIT: resp. toto Kód: $input = preg_replace("#\shttp(s)?://([^,\s]+)\s#"," <a href=\"http://$2\" target=\"_blank\">$2</a> ", $input); $input = preg_replace("#\swww.([^,\s]+)\s#"," <a href=\"http://$1\" target=\"_blank\">$1</a> ", $input);
_________________
A. S. Tanenbaum píše: The terms LF, MF, and HF refer to low, medium, and high frequency, respectively. Clearly, when the names were assigned, nobody expected to go above 10 MHz, so the higher bands were later named the Very, Ultra, Super, Extremely, and Tremendously High Frequency bands. Beyond that there are no names, but Incredibly, Astonishingly, and Prodigiously high frequency (IHF, AHF, and PHF) would sound nice. |
|
Registrovaný: 09.09.07 Prihlásený: 07.11.16 Príspevky: 3114 Témy: 233 | 233 Bydlisko: Nové Zámky |
To druhe je fajn, to prve mi vratilo nic - (samozrejme, premenne som spravne prepisal)
Da sa este taka vec spravit, aby mi to nemazalo zariadkovanie?
ked dam:
Kód: bla bla www.nieco.sk
nieco tak mi to zmaze zariadkovanie.. EDIT: tak som sa este viac povrtal v phpBB zdrojakoch a nasiel som: Kód: function make_clickable($text) { $text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text);
// pad it with a space so we can match things at the start of the 1st line. $ret = ' ' . $text;
// matches an "xxxx://yyyy" URL at the start of a line, or after a space. // xxxx can only be alpha characters. // yyyy is anything up to the first space, newline, comma, double quote or < $ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $ret);
// matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing // Must contain at least 2 dots. xxxx contains either alphanum, or "-" // zzzz is optional.. will contain everything up to the first space, newline, // comma, double quote or <. $ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret);
// matches an email@domain type address at the start of a line, or after a space. // Note: Only the followed chars are valid; alphanums, "-", "_" and or ".". $ret = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret);
// Remove our padding.. $ret = substr($ret, 1);
return($ret); }
Funguje ! Dakujem moc za rady
_________________ "It took a lot of work, but this latest Linux patch enables support for machines with 4096 CPUs, up from the old limit of 1024." "Do you have support for smooth full-screen flash video yet?" "No, but who uses that?"
- ak dlho neodpisujem do témy, zabudol som na ňu, takže ma upozornite SS, ak chcete moju odpoveď |
|
Stránka: 1 z 1
| [ Príspevkov: 6 ] | |
Podobné témy | Témy | Odpovede | Zobrazenia | Posledný príspevok |
---|
| v Redakčné systémy | 3 | 612 | 08.10.2006 13:53 matasss | | v Ostatné programy | 6 | 636 | 21.06.2021 21:34 tairikuokami | | v PHP, ASP | 21 | 1327 | 07.07.2008 21:25 idiotart | | v HTML, XHTML, XML, CSS | 1 | 582 | 06.04.2012 18:41 iop | | v HTML, XHTML, XML, CSS | 4 | 421 | 21.12.2012 19:45 dado1812 | | v Ostatné | 7 | 1682 | 30.11.2008 11:59 Blackshadow | | v JavaScript, VBScript, Ajax | 5 | 595 | 07.03.2012 22:17 phodinux | | v PHP, ASP | 6 | 522 | 27.02.2012 14:28 emer | | v JavaScript, VBScript, Ajax | 3 | 539 | 25.09.2010 2:58 Dolmayan | | v PHP, ASP | 6 | 556 | 19.07.2008 16:25 fotograf | | v JavaScript, VBScript, Ajax | 4 | 471 | 09.09.2011 19:08 camo | | v PHP, ASP | 2 | 392 | 04.01.2012 0:54 1daemon1 | | v Assembler, C, C++, Pascal, Java | 9 | 563 | 12.11.2017 18:22 17mark | | v PHP, ASP | 2 | 426 | 11.06.2010 20:05 dartanan | | v PHP, ASP | 2 | 1001 | 22.05.2009 21:25 roach189 | | v Internetový marketing, SEO, reklama | 4 | 977 | 06.10.2008 13:22 Codik |
|