View Single Post
Old 12-06-2004, 04:26 AM   #5 (permalink)
idx
Senior Grasshopper
 
idx's Avatar
 
Join Date: Jun 2003
Location: FL
Posts: 317
idx is on a distinguished road
preg_replace is probably the most direct route to go with this. Here's a quick example that works on comments and (0:7) lines:

PHP Code:

  $srch 
= Array(
     
'/^(\*.*)/',
     
'/\((\d*\:\d*)\)/',
  );
  
$replace = Array(
     
"<font color=aqua>\${1}</font>",
     
"(<font color=green>\${1}</font>)",
  );

  
$str preg_replace($srch$replace$foo); 
Instead of trying to create one regex for all replacements you can just keep adding search/replace items to the arrays and it'll be easier to maintain.

-r
idx is offline   Reply With Quote