469,923 Members | 1,548 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,923 developers. It's quick & easy.

regular expression

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
Jul 19 '05 #1
2 1675
hugo wrote:
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;

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Jul 19 '05 #2
Why don't you just use a split statement.... It woudl be faster then a rege
exp.
"hugo" <hu******@yahoo.com> wrote in message
news:81**************************@posting.google.c om...
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

Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Buddy | last post: by
4 posts views Thread by Neri | last post: by
11 posts views Thread by Dimitris Georgakopuolos | last post: by
3 posts views Thread by James D. Marshall | last post: by
7 posts views Thread by Billa | last post: by
9 posts views Thread by Pete Davis | last post: by
25 posts views Thread by Mike | last post: by
1 post views Thread by NvrBst | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.