chomp


Description:

public string chomp ()

Removes trailing whitespace from a string.

Example: Remove trailing whitespace:

public static int main (string[] args) {
string my_wisdom = " Gallifrey. I've not heard of it. Perhaps it's in Ireland. \t ";
string res = my_wisdom.chomp ();

// Output:
// ``' Gallifrey. I've not heard of it. Perhaps it's in Ireland. '``
// ``' Gallifrey. I've not heard of it. Perhaps it's in Ireland.'``

print ("'%s'\n", my_wisdom);
print ("'%s'\n", res);

return 0;
}

valac --pkg glib-2.0 string.chomp.vala

Returns:

a newly-allocated string holding the result

See also:

string._chomp, string._chug, string._strip, string.chug, string.strip