Regexp for variable length tags



I am processing some data that has a up to three key-value pairs concatenated together. The keys can be "ADD, REM, EQD". Values are variable length.

There will always be an "ADD" section, followed by 0 to 1 "REM" sections, followed by 0 to 1 "EQD" sections. For example:
ADDxxxxxxxxREMyyyyyEQDzzzzz


I'm trying to find a regular expression that will split this apart into separarate sections in one step.

So far, I have this:

$rec =~ /(ADD.+)(REM.+)(EQD.+)/;

But, this only works if I know the record has all three tokens.

This gobbles too much:
$rec =~ /(ADD.+)(REM.+)?(EQD.+)?/;

Any ideas?

-Jon
.



Relevant Pages