preg_replace: how do I strip off all white spaces and  ?

Hi,

how do I strip off all white space and  ?

I have this as a input in a wrapper I create,

      bold      

so before turning the text to bold, i want to strip off all white spaces and &nbsp, and turn it into bold,

$this->content = preg_replace("/\\[(.*?)\\]\\s\\s+(.*?)\\s\\s+\\[\\/(.*?)\\]/", 
				"[$1]$2[/$3]", 
				$this->content);

but it does not work! can you help please?

Many thanks,
Lau

yes it is a form input pass from tiny MCE and it generates   when u put spaces in the form input.

I got it sorted with the code below,

$this->content = preg_replace( '/\\[([a-z]+)\\](?: |\\s)*(.*?)(?: |\\s)*\\[\\/([a-z]+)\\]/', '[$1]$2[/$3]', $this->content );
		$this->content = preg_replace( '/\\[([a-z]+)\\=\\"(.*?)\\"\\](?: |\\s)*(.*?)(?: |\\s)*\\[\\/([a-z]+)\\]/', '[$1="$2"]$3[/$4]', $this->content );

thanks so much!
:smiley:

Is this part of a form? Can you say what exactly is not working? Are you getting an error message?