Prev | Current Page 160 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

The most ugly of these are
those appended to the beginning or end of your string, which can throw your string algorithms if
unexpected. Luckily, StringTools provides several methods for dealing with these pesky characters.
You can check if a character in your string is a space character using the isSpace method. This method
accepts the string you wish to examine as the first parameter and the location of the wanted or unwanted
space character as the second parameter. If the character at that location is indeed a space, then the
Boolean value true is returned:
var tmp = StringTools.isSpace(myStr, 4); // returns true from ???haXe and Neko???
Removing unsightly spaces from the beginning or end of your string can be performed using trim ,
ltrim , and rtrim . The trim method removes spaces from both sides of your string, while ltrim only
removes spaces from the left side of your string and rtrim only from the right. All three of these methods
will remove every space that exists at the relevant end of your string, even if it has a bazillion of them.


Pages:
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172