Regex-style pattern-matching for non-text?

C

Calum MacLean

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?

Thanks,
Calum
 
H

hiwa

Calum MacLean said:
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:
Have in what? In a Java Collection like ArrayList?
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?

Thanks,
 
?

=?ISO-8859-1?Q?Daniel_Sj=F6blom?=

Calum said:
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?

I saw a project on sourceforge that proclaimed to do what
you want. So visit sourceforge.net and see if you can find it (I don't
remember the name of the app, and it may have been vaporware like so
many other 'projects' on sourceforge)
 
C

Calum MacLean

Hi

Part of what I envisaged in such a framework would be that how you
stored your objects etc. would be open, and what your objects were
would be open.

One of my example usages was elements in an XML document - checking
the child elements of a certain element.
So in general the objects could be in an already-defined structure,
and I was thinking that the framework would let you implement an
adapter to that structure.

Calum
 
C

Calum MacLean

Thanks.

I did have a search in SourceForge and didn't find anything. I'll
maybe go back and have a quick look with different criteria.

Calum

Daniel Sjöblom said:
Calum said:
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?

I saw a project on sourceforge that proclaimed to do what
you want. So visit sourceforge.net and see if you can find it (I don't
remember the name of the app, and it may have been vaporware like so
many other 'projects' on sourceforge)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top