General String Quick Overview
My free software page.
The General String library was inspired by the Icon programming language string
manipulation features. This library has a GNU license,
i.e. it is free. I encourage you to get acquainted with the GNU license and support it if
you agree with it.
Icon has two interesting features that are very useful in string manipulation:
Next is a simple example to show the elegance of these concepts. Suppose that you want to parse a string to find the indexes of vowels:
GString source = new GString("Hello world"); // String to be parsed
SetChar target = new SetChar("aeiou"); //
Vowels
IGenerator g = source.doGenerate().find().generator(target); //
a find generator
Variant v; // a variant to hold
generated positions
// loop until no more generations
do {
v= g.next(); // get next position
if (g.ok()) // if
successful generation then print position
System.out.println(v);
} while (g.ok());
The above example will print:
1
4
7
Here are some pointers to get more information about the Icon language:
Page Last Updated October 16, 2001.