RegularExpression-esque search matching Objects in List
- by Pindatjuh
I'm currently working on an implementation of the following idea, and I was wondering if there is any literature on this subject.
Working with Java, but the principle applies on any language with a decent type-system, I like to implement: matching Objects from a List using a RegularExpression-esque search:
So let's say I have a List containing
List<Object> x = new ArrayList<Object>();
x.add(new Object());
x.add("Hello World");
x.add("Second String");
x.add(5); // Integer (auto-boxing)
x.add(6); // Integer
Then I create a "Regular Expression" (not working with a stream of characters, but working with a stream of Objects), and instead of character-classes, I use type-system properties:
[String][Integer]
And this would match one sublist: {Match["Second String", 5]}. The expression:
[String:length()<15]
Will match two sublist (each of length 1) containing a String which instance is passing the expression instance.length() < 5: {Match["Hello World"],Match["Second String"]}.
[Object][Object]
Matches any pair in the List: {Match[Object,"Hello World"],Match["Second String", 5]}, in a streamed manner (no overlapping matches).
Ofcourse, my implementation will have grouping, lookahead/lookbehinds and is hierarchical (i.e. matching n elements from Lists in Lists), etc. The above merely illustrates the concept.
Is there a name for this principle, and is there literature available on it?