gstring

The General String library was inspired by the Icon programming language string manipulation features.
Download

gstring Ranking & Summary

Advertisement

  • Rating:
  • License:
  • GPL
  • Price:
  • FREE
  • Publisher Name:
  • gstring Team
  • Publisher web site:
  • http://www.tek271.com/free/gsoverview.html

gstring Tags


gstring Description

The General String library was inspired by the Icon programming language string manipulation features. 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: Generators: A construct that can generate a sequence of values, and fails when no more values are available.This is somewhat similar to Java's Iterator. This General String library supports generators through the IGenerator interface.Backtracking: An operation can consist of two (or more) generators associated together, e.g. through an operator, if the second generator fails, we backtrack to the first generator and retry the operation again.Think of a database transaction to help you understand backtracking, although they are different. This General String library supports backtracking through the operator classes in the gstring.operators package.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


gstring Related Software