PHP tags dislike regular expression syntax...

We know you have an opinion on how things should be run around here. These are suggestions for the forums, and the website.This forum is not a place to ask for suggestions to your own coding (or otherwise) problems.

Moderator: General Moderators

Post Reply
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

PHP tags dislike regular expression syntax...

Post by Maugrim_The_Reaper »

Code: Select all

<?php

$string = 'http://www.mydomain.com/index.php?st=1';
echo preg_replace('/[^[:alnum:].]/', '_', $string); //http___www.mydomain.com_index.php_st_1

?>
When put between php tags removes the :alnum: range in regex like so...

Code: Select all

<?php

$string = 'http://www.mydomain.com/index.php?st=1';
echo preg_replace('/[^[].]/', '_', $string); //http___www.mydomain.com_index.php_st_1

?>
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I would love to find a syntax highlighter that doesn't have any bugs :(
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

+1 :) Sorry to be the bearer of buggy news...
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

I have to admit, that syntax highlighter seems to have been a bad move at least for the

Code: Select all

 tags.  Perhaps it will be rolled back at the next upgrade.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

I wouldn't say it's a lost cause - we probably exercise it to a whole new level seeing as Devnetwork is one of those all you can eat PHP help buffets...
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

And I would say that for the most part it has been a useful tool, even for seasoned developers that see the code they posted and immediately saw something that broke the higlighter and knew right away what the problem was.

I agree it'd be nice to have one that works, but I am still happy with the one we got.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Maugrim_The_Reaper wrote:I wouldn't say it's a lost cause - we probably exercise it to a whole new level seeing as Devnetwork is one of those all you can eat PHP help buffets...
True :) Geshi by itself works nicely. It's when you mix it with PHPBB's bbcode.php mod that it all starts to go pear shaped. There's pre/post -processing on the data so things get interefered with that should be.
Post Reply