PDA

View Full Version : Spaces


Kyranki
08-28-2007, 06:47 PM
public function removeAllSpaces(text) {
temp.toks = text.tokenize();
for (temp.str : temp.toks) {
if (temp.str == " ") {
continue;
}
temp.out @= temp.str;
}
return temp.out.trim();
}
//#CLIENTSIDE
public function removeAllSpaces(text) {
temp.toks = text.tokenize();
for (temp.str : temp.toks) {
if (temp.str == " ") {
continue;
}
temp.out @= temp.str;
}
return temp.out.trim();
}


This removes all spaces everywhere on a join. A simple usage of this would be something like.


function onCreated() {
join("util_spaces");
temp.string = " Lollin @ Chompy";
echo(removeAllSpaces(temp.string));
}


^ That would echo: "[email protected]";
Just for some of those minor irritations that are too minor to add a built in function for.

Twinny
08-28-2007, 07:04 PM
I don't think spaces are included in the return from tokenize(); In the end, you could easily loop the array without the need to check for spaces.

Kyranki
08-28-2007, 07:11 PM
Err, well I'll check it out later. I think it is tho, not sure.

Edit: Actually you're right because space is the delimiter. Thanks Twinny. ;P

Chompy
08-28-2007, 07:20 PM
<3


public function removeSpaces(str) {
temp.out = 0;
for(temp.t : str.tokenize()) out @= t;
return out;
}

Oh, and lol back at you :p
<3

Kyranki
08-29-2007, 04:27 AM
<3


public function removeSpaces(str) {
temp.out = 0;
for(temp.t : str.tokenize()) out @= t;
return out;
}

Oh, and lol back at you :p
<3

<3