php - preg_replace: how do I strip off all white space and ? -



php - preg_replace: how do I strip off all white space and  ? -

how strip off white space ,  ?

i have input in wrapper create,

[b]       bold       [/b]

so before turning text bold, want strip off white spaces , &nbsp, , turn [b]bold[/b],

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

but not work! can help please?

there no need regex based solution. can utilize str_replace as:

$input = "[b]       bold       [/b]"; $input = str_replace(array(' ',' '),'',$input); echo trim($input); // prints [b]bold[/b]

php regex preg-replace whitespace

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -