Leave Comments, Critiques, and Suggestions Here?
Find, Replace and friends
The tango.text.Util is a collection of templated helper functions. The module doc (previous link) has a summary and usage examples. The contained functions can handle UTF8/16/32.
Note: you can also use generic array functions on a string. See tango.core.Array
import tango.text.Util; void test1(){ locate( "abcdef", "cd" ); // returns 2 }
tango.text.Util also contains are very lightweight layouter that allows the composition of strings in an easy and efficient way. However it can only handle string arguments and doesn't do any convertion.
import tango.text.Util; void test1(){ char[100] buffer = void; // save the time for initialization (=void) char[] result = layout( "%1 is after %0", "zero", "one" ); // result is "zero is after one" }
Regular Expressions
Regular expressions lets you search for special patterns. You can retrieve parts of the match and do search replace actions.
Please see the module documentation tango.text.Regex.
Ascii and Unicode
The Ascii module offers functions for toLower(), toUpper(), compare(), icompare().
Please see the module documentation tango.text.Ascii
Note: Ascii is only the character value 0..127, everything above is something else. In D the char type is UTF8 which is different to eg. ISO-8859-1 (fequently confused with Ascii). If you need to convert from or to something else then Ascii, an external library is needed. E.g. see the mango project, there is a binding to the ICU lib, that can hanlde every encoding.
The tango.text.Unicode offers also test and convertion functions for single Unicode characters. E.g. toLower(), toUpper(), isSpace(), isPrintable(), ...
Please see the module documentation tango.text.Unicode
Note: to convert whole unicode string from one encoding into another (utf8/16/32) see Chapter Convertions - Utf
Store and manipulate Text
INI Files aka Properties
The Properties module has the static load() and save() functions, for loading Property files. This is a file format, where each line is of the format
# comment key = value
Please see the module documentation tango.text.Properties
Links
Given some text, a file, or a buffer, this will emit all lines contained:
High level representation of a text string, with support for insert, remove, append, printf-style formatting, layout, utf conversion, custom comparison, etc. Also includes an immutable variant:














