Re: Regex repeating capture
- From: Todd <null@xxxxxxxxxxx>
- Date: Tue, 30 Jan 2007 11:54:16 -0600
Jay wrote:
Howdy,my $line = '*CZ1 2.3 4-56 *fuuuS24364 08 23 72';
I'm trying to break an input string into multpile pieces using a series of delimiters that start with an asterisk. Following the asterisk is a mulitple character identifier immediately followed by a
data string of variable length. The input string may contain more than one identifier anywhere in the string. In all, there are 50+ identifiers to search for and the asterisk is allowed to part of the data string as long as it isn't defined as an identifier (it would be treated as another identifier at that point).
Here is a simple example:
*CZ1 2.3 4-56 *fuuuS24364 08 23 72
I'd like to break this into
CZ
1 2.3 4-56
fuuu
S24364 08 23 72
I have tried the pattern (?:\*(CZ|fuuu)(.*)), which produces the
following ouput:
CZ
1 2.3 4-56 *fuuuS24364 08 23 72
How can I force it to repeat the capturing?
Thanks,
Jay
$line =~ /\*(CZ)(.+)\s+\*(fuuu)(.+)\s*$/;
# $1 = CZ
# $2 = 1 2.3 4-56
# $3 = fuuu
# $4 = S24364 08 23 72
Todd
.
- References:
- Regex repeating capture
- From: Jay
- Regex repeating capture
- Prev by Date: Re: Regex repeating capture
- Next by Date: Re: Regex repeating capture
- Previous by thread: Re: Regex repeating capture
- Next by thread: Re: Regex repeating capture
- Index(es):
Relevant Pages
|