regular expression

H

hugo

I would like a regular expression that can recognized 1 or more
segments which are variable length. Say each segment is of the form
TAGxxxx, where the number of x's is arbitrary. I want to parse records
like the following,

TAGxxx
TAGxxxxxTAGxx
TAGxxTAGxxxxxxTAGxxxxxxxx

and so on. (TAG(.*))+ finds the first TAG and then gobbles the rest. I
want to find as many TAG(.*)'s as possible, not the fewest possible.

Thanks
 
G

Gunnar Hjalmarsson

hugo said:
I would like a regular expression that can recognized 1 or more
segments which are variable length. Say each segment is of the form
TAGxxxx, where the number of x's is arbitrary. I want to parse
records like the following,

TAGxxx
TAGxxxxxTAGxx
TAGxxTAGxxxxxxTAGxxxxxxxx

and so on. (TAG(.*))+ finds the first TAG and then gobbles the
rest. I want to find as many TAG(.*)'s as possible, not the fewest
possible.

my @tags = /TAG.*?(?=TAG|\n)/g;
 
B

Blaine Everingham

Why don't you just use a split statement.... It woudl be faster then a rege
exp.
 

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
474,262
Messages
2,571,059
Members
48,769
Latest member
Clifft

Latest Threads

Top