Regular expression style pattern matching for data

Status
Not open for further replies.

Mears

Ars Scholae Palatinae
983
A long time ago, I wrote a utility for an employer that allowed testers to perform verification on data coming out of a hardware box using a regular expression language. It allowed users to evaluate expressions against live or archived data like: "packetA packetB* packetC". Of course, the users of this library had to provide a parser for breaking the data into individual units. For more sophisticated checks, it had the ability to attach filters to the tokens: "packetA packetB<startFlag> packetB+ packetB<endFlag> packetC". The <startBit> and <endBit> tags would be matched to user specified callbacks that could do deeper inspection on the data outside of simple id. In this contrived example, verifying that a start flag is set and an end flag is set.

It seemed like a fairly powerful utility at the time, and was an interesting little project to develop. I was considering developing another version of it, but I'm having a hard time determining if this type of analysis is really broadly useful. Can anyone think of any problems such a utility would help solve?
 

Mears

Ars Scholae Palatinae
983
I know what regular expressions are. I guess I'm missing what in xutools does that is similar, and I'm not sure what either of those wikipedia articles were trying to show me. Context?

At its core, regular expressions generate state machines (NFAs/DFAs) where transitions between states are based on a token (character). The utility I'm describing is similar, except that instead of using characters for transitions, it uses IDs. Big deal; this much could be accomplished by turning packets into a concatenated string of IDs and using a standard regular expression library. The more important difference is that you can attach qualifiers/filters to the transitions to do more detailed analysis of the underlying data.
 

Apteris

Ars Tribunus Angusticlavius
9,590
Subscriptor
I know what regular expressions are. I guess I'm missing what in xutools does that is similar, and I'm not sure what either of those wikipedia articles were trying to show me. Context?
They were meant as hints towards possible uses of the technology you described.

The problem, I think, is that what you're proposing isn't specific enough. Unless I'm misunderstanding, you're basically thinking of the map pattern and/or filter function. Asking what you can do with those is a little like asking "where can I drive my car?"

Look at map/reduce. Is that similar to what you're proposing?
 

ShuggyCoUk

Ars Legatus Legionis
10,387
Subscriptor++
Regular Expressions are useful because they understand their input domain well (text).
You can refer to whitespace, ranges of values, types of letters, 'word' concepts etc.

Doing a generalised equivalent for binary can be done, but the input domain becomes an awful lot more general, and any language targeting it either less useful, or way more complex (and textual regular expressions are pretty complex already!) as you try to throw the kitchen sink at it.

For introspecting specific sorts of binary streams/files powerful tools already exist, e.g. wireshark bitblaze, etc.

If you're writing a framework without a use case you're doing it wrong. Better yet write a specific tool for a problem you (or someone you know well) wants to sove.
 
Status
Not open for further replies.