view mde/text/util.d @ 4:9a990644948c

Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more. committer: Diggory Hardy <diggory.hardy@gmail.com>
author Diggory Hardy <diggory.hardy@gmail.com>
date Sun, 06 Jan 2008 17:38:51 +0000
parents 78eb491bd642
children
line wrap: on
line source

/***************************************************************
 * A collection of text utility functions.
 *
 * Authors: Diggory Hardy, diggory.hardy@gmail.com
 * Copyright: Copyright © 2007 Diggory Hardy.
 * License: Licensed under the Academic Free License version 3.0
 **************************************************************/
module mde.text.util;

/** Trim space and tab chars from the end of a string.
 *
 * No static arrays OK?? */
T postTrim(T) (T str) {
    uint i = str.length;
    for (uint j; i > 0; i = j) {
        j = i - 1;
        if (str[j] != ' ' && str[j] != '\t') break;
    }
    return str[0..i];
}
unittest {
    assert (postTrim(" 	a6 05 	   ".dup) == " 	a6 05".dup);
}