Re: [PHP] Preg_match - Find URL and convert to lower case
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', '"www." . strtolower("$1") . "\" target=\"_blank\">http://www."; . strtolower("$1") . ""', $section_notes); $section_notes = eregi_replace("(([a-z0-9_]|\\-|\\.)+@([^[:space:]]*) ([[:alnum:]-]))", "mailto:\\1\";>\\1",$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
Re: [PHP] Preg_match - Find URL and convert to lower case
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. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: SOLVED: [PHP] Preg_match - Find URL and convert to lower case
$section_notes = preg_replace('/WWW.(.*?) /e', '"www." . strtolower("$1") . "\" target=\"_blank\">http://www."; . strtolower("$1") . ""', $section_notes); For some reason I can't get it to work if I decare those items as variables. They have to be inside the preg_replace as written. But, it works now. Thanks for the help. -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada Community College www.wncc.edu 775-445-3326 On Nov 30, 2006, at 3: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? -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada Community College www.wncc.edu 775-445-3326 On Nov 30, 2006, at 2:26 PM, Dave Goodchild wrote: Why not use strtolower on the string after the replacements have been made? -- http://www.web-buddha.co.uk
Re: [PHP] Preg_match - Find URL and convert to lower case
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? -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada Community College www.wncc.edu 775-445-3326 On Nov 30, 2006, at 2:26 PM, Dave Goodchild wrote: Why not use strtolower on the string after the replacements have been made? -- http://www.web-buddha.co.uk
Re: [PHP] Preg_match - Find URL and convert to lower case
Why not use strtolower on the string after the replacements have been made? -- http://www.web-buddha.co.uk
[PHP] Preg_match - Find URL and convert to lower case
I have some text that comes out of a database all in uppercase (old IBM Mainframe that only supports uppercase characters). Occasionally there are web addresses in this text and so I am trying to find them, convert them to a link, and convert them all to all lower case. Yes, I know that will not work for all links. However, it will work for about 90% of the links I have (vs. about 10% of them now). So anyway, here is my first stab at this, but it only finds the link and converts the first part to lowercase and converts it to a link. Is there anyway to convert the output to all lowercase by doing something like this? Or is there a better way? $pattern = "/WWW.(.*?) /i"; $replace = "http://www.\\1\";>http://www.\\1"; $section_notes = preg_replace($pattern,$replace,$section_notes); -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada Community College www.wncc.edu 775-445-3326