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 ,  , , 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
Post a Comment