I have a sequence of "objects" which must occur in a certain order, with optional items etc.
As I've been using regex's quite a bit of late, it struck me that it might be useful to do a similar thing for arbitrary objects, rather than just for text characters.
For example, if I have objects A, B, C, D and E, and:
they must occur in the sequence in that order (if present) B is optional exactly one of D and E must be present.
then it would be nice to be able to specify this as "AB?C[DE]" - or something equivalent.
Does this make sense? Do you know if there are any libraries available to allow you to do this sort of thing?
What are A, B, C, D and E? Classes Names or instances? Because they are y upercase I assume they are Classes so I'm thinking in an Object array target and the need of know if it complains that regex. If so: why don't you concat the array elements getClass().getName() and try to match the following regex: