Re: removing whitespaces
- From: "Janwillem Borleffs" <jw@xxxxxxxxxxxxx>
- Date: Mon, 27 Feb 2006 22:07:38 +0100
rj wrote:
This works great, but makes no handles all characters in the same
way. I want to preserve data between double quotes. So,
hello world "It is a sunny... world"
shall be reduced to
hello world "It is a sunny... world"
and should not remove the whitespaces between the quotes.
$str = 'hello world "It is a sunny... world"';
function cb($m) {
if (trim($m[1])) {
return $m[1];
}
return ' ';
}
$str = preg_replace_callback('/(\s+|"[^"]+")/','cb', $str);
JW
.
- References:
- removing whitespaces
- From: rj
- removing whitespaces
- Prev by Date: Re: Matching IP scopes.
- Next by Date: Podwójne queries - MySQL
- Previous by thread: removing whitespaces
- Next by thread: Podwójne queries - MySQL
- Index(es):