Re: Preg_match - Find URL and convert to lower case

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Dec 1, 2006, at 1:56 PM, Richard Lynch wrote:

On Thu, November 30, 2006 5:04 pm, Kevin Murphy wrote:
Well the problem would be then that the entire string would be lower
case, and I only can have the link as lower case. Is there a way to
apply strtolower into the preg_match?

Why not use lower(link) in SQL to get the link out in the first place?

Also, the domain part cannot be case-sensitive, so you needn't worry
about that part.

For the 10% that don't work, a quick check with common variants on
capitalization might help to fix those up.

Since these are mostly instructor's websites, that last 10% I figure it would be easier to just ask the instructors to change their site addresses.

Since these are in the middle of the text, I don't think that lower will work. Doesn't it just do the same thing as strtolower? The query as is right now is (edited) "select note_text as note_text from classes" where note_text is many lines of text and in the middle of some are links and emails.

What I ended up with, is this, which takes care of website addresses and emails as well (although those stay all-caps). The str_replace is there because some have the HTTP and some don't and I figured it was easier to just wipe them all out first.

$section_notes = str_replace("HTTP://","",$section_notes);
$section_notes = preg_replace('/WWW.(.*?) /e', '"<a href=\"http:// www." . strtolower("$1") . "\" target=\"_blank\">http://www."; . strtolower("$1") . "</a>"', $section_notes); $section_notes = eregi_replace("(([a-z0-9_]|\\-|\\.)+@([^[:space:]]*) ([[:alnum:]-]))", "<a href=\"mailto:\\1\";>\\1</a>",$section_notes);

Anyone have a better idea on how to accomplish the same thing?

--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux