How would I remove the spaces between these two "words"
Input:
[/TD] [TD="align: left"]
Output:
[/TD][TD="align: left"]
All I know is it needs regex but i don't know anything about it.
How would I remove the spaces between these two "words"
Input:
[/TD] [TD="align: left"]
Output:
[/TD][TD="align: left"]
All I know is it needs regex but i don't know anything about it.
The easiest way would just be to remove any spaces between ]
and [
, if that words for you.
$string = '[/TD] [TD="align: left"]';
$string = preg_replace('/\]\s+\[/', '][', $string);
If it is only this string you want to alter, a simple str_replace will do the job for you...
$string = '[/TD] [TD="align: left"]';
echo str_replace('] [','][',$string);
or to save to a new variable
$stringnowhite = str_replace('] [','][',$string);
try this:
$string = '[/TD] [TD="align: left"]';
$string = preg_replace('/\]\s*\[/', '][', $string);