Skip to content
Snippets Groups Projects
Commit dac626c1 authored by Martin Nilsson's avatar Martin Nilsson
Browse files

Added trim_whites and trim_all_whites.

Rev: lib/modules/String.pmod:1.9
parent 4ad4cd94
No related branches found
No related tags found
No related merge requests found
......@@ -171,3 +171,27 @@ int fuzzymatch(string a, string b)
return fuzz;
}
string trim_whites( string what )
{
if (stringp (what)) {
sscanf(what, "%*[ \t]%s", what);
string rev = reverse(what);
sscanf(rev, "%*[ \t]%s", rev);
return what[..strlen(rev) - 1];
}
return what;
}
string trim_all_whites( string what )
{
if (stringp (what)) {
sscanf(what, "%*[ \t\r\n]%s", what);
string rev = reverse(what);
sscanf(rev, "%*[ \t\r\n]%s", rev);
return what[..strlen(rev) - 1];
}
return what;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment