Probably something like this...
$str = [hi] there, this is me [HI][HI] there, this is me;
$newstring = ereg_replace((\[[A-Z]*][^]]), br\\1, $str);
I'm not sure if the [^]] should be [^\]] or not, but that might work.
If it doesn't you could always do:
$str = [hi] there, this is me [HI][HI] there, this is me;
$newstring = ereg_replace((\[[A-Z]*]), br\\1, $str);
$newstring = ereg_replace(]br\[, ]\[, $newstring);
Regular expressions are your best friend :) You might checkout this book.
It uses Perl's regex's, but PHP has support for them and it seems that
more and more apps are using Perl's (well, PHP and vim both use them and I
don't use anything else :)
http://www.oreilly.com/catalog/regex/
-philip
On Thu, 13 Dec 2001, Boget, Chris wrote:
This is untested, but something like...
$str = [hi] there, this is me [HI] there, this is me;
$newstring = ereg_replace((\[[A-Z]*]), br\\1, $str);
should do it.
using the Perl regexe's might make it easier, but that should work.
That worked perfectly. Is there any way I can make it so that
it'll put the br there in every instance except for when it's
preceded by another square bracket.
So this:
[hi] there, this is me [HI] there, this is me
would turn into this:
[hi] there, this is me br[HI] there, this is me
(which is the script that you sent me and works beautifully)
but this:
[hi] there, this is me [HI][HI] there, this is me
won't turn into this:
[hi] there, this is me br[HI]br[HI] there, this is me
?
Chris
-still learning regular expressions
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]