Regexp for variable length tags
- From: Jon Burroughs <Jon@xxxxxxxxxx>
- Date: Mon, 18 Jul 2005 16:07:36 -0400
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 .
- Follow-Ups:
- Re: Regexp for variable length tags
- From: Gunnar Hjalmarsson
- Re: Regexp for variable length tags
- From: Jim Gibson
- Re: Regexp for variable length tags
- From: John W. Krahn
- Re: Regexp for variable length tags
- Prev by Date: Creating an array from file input
- Next by Date: Re: Creating an array from file input
- Previous by thread: Creating an array from file input
- Next by thread: Re: Regexp for variable length tags
- Index(es):
Relevant Pages
|