Hi gurus. I'm having fun replacing the text within [ and ] to XML format on 4000+ files on a windows XP machine. I installed php (and an apache server) on the machine because it is the only language the I am remotely familiar with. I want and text that is with [ and ] to be enclosed with <note> and </note>. Going through the archives I found this nice regex (I changed it a bit- I hope that I didn't break anything important) that fits into str_replace: str_replace("/[([a-zA-Z]+?)]/", "<note>".$what was_inside_the_parethesis."</note>", $string); But how on sweet mother Earth do I get the $what was_inside_the_parethesis variable to stick into the note tags? I tried functions that would remove the [ and ], then do $new_str="<note>".$what was_inside_the_parethesis."</note>"; and then replace the whole [$what was_inside_the_parethesis] with $new_str. I did get that far. Now the catch! If $what_was_inside_the_parethesis contains the word 'algebra' then I want nothing returned- in other words [$what was_inside_the_parethesis] should be cut out and nothing put in it's place. I added an if function in there that checked the presence of the word algebra, but it ALWAYS returned blank. So I went changing this and changing that, and now I'm very frustrated because I did not save the code that WAS working before I added the 'remove algebra' clause... and I can't seem to get back to that state again! Is there a clean way to do this in a str_replace or two? Or should I just start from scratch again with all my if's and preg_match'es? I had a good 10-15 lines of code in there. I don't mind redoing it, I just want to know if it can be done simpler? And I'm not too sure that I'll succeed in the 'remove algebra' clause. Thanks all. Dotan http://lyricslist.com/lyrics/artist_albums/64/beatles.php Beatles Song Lyrics -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php