Re: How do I do this

From: Date: Thu, 13 Dec 2001 21:13:42 +0000
Subject: Re: How do I do this
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-77675@lists.php.net to get a copy of this message
In <4040BBE81A9AD411BD27009027887A7C043114@tiger.wild.net>, Chris Boget wrote: Either of these should work: $str = preg_replace("/(\[[A-Z]+\])/","<br>\\1",$str); $str = ereg_replace("(\[[A-Z]+\])","<br>\\1",$str); e.g.: <?php $str = "[hi] there, this is me [HI] there, this is me"; print($str); $str = preg_replace("/(\[[A-Z]+\])/","<br>\\1",$str); //$str = ereg_replace("(\[[A-Z]+\])","<br>\\1",$str); print("$str"); ?> Jeff Warrington > I've got the following possible (example) strings: > > [hi] there, this is me [HI] there, this is me [ho] there, that is you > [HO] there, that is you [hey] there, where are you [HEY] there, where > are you > > and so on. I'm trying to come up with a regex that will find the > capitalized text (only) between the square brackets, including the > brackets (ie, the [HI], [HO], [HEY]) and basically put a <br> right > before. So, after the regex/replace, it'll look like this: > > [hi] there, this is me <br>[HI] there, this is me [ho] there, that is > you <br>[HO] there, that is you [hey] there, where are you <br>[HEY] > there, where are you > > Now, the text between the brackets will be unknown, so I can't just do > an instr() or strstr(). > > Any suggestions? > > Chris >

« previous php.general (#77675) next »