Hey guys, how are ya?
This regex script has been working great! However I found one little bug... This code makes all of the HTML tags lower case which works fine:
$content =preg_replace('/(<[^>]+>)/ies','strtolower("\\1")',$content);
However, lets say I have an image called ImAgE.JPG. And then I have this code: <img src="ImAgE.JPG">. The regex script then makes the images name lower case which ends up like this: <img src="image.jpg">...
Because the linking to the image is case sensitive, it then gives a 404 error on the image. Is there anyway around this?
Regex and Lowercase issues...
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Code: Select all
$content =preg_replace('/(?:<(\/?\w+)[^>]+>)/ies','strtolower("\\1")',$content);- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Yeah sorry... I've had one of those day lol....
untested... but you get the idea (should be easy to fix if it's broken)
untested... but you get the idea (should be easy to fix if it's broken)
Code: Select all
$content =preg_replace('/(?:<(\/?\w+)([^>]+)>)/ies','<'.'strtolower("\\1")'.'\\2>',$content);Not quite... The errord11wtq wrote:(should be easy to fix if it's broken)
I tried replacing '<'.'strtolower("\\1")'.'\\2>' with '<'.strtolower("\\1").'\\2>' but no luck...Parse error: parse error, unexpected '<' in c:\program files\easyphp\www\created\oe_content_manager_v2\html2xhtml\test.php(11) : regexp code on line 1
Fatal error: Failed evaluating code:
in c:\program files\easyphp\www\created\oe_content_manager_v2\html2xhtml\test.php on line 11