Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > regular expression

Reply
Thread Tools

regular expression

 
 
hugo
Guest
Posts: n/a
 
      01-07-2004
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
 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      01-07-2004
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

 
Reply With Quote
 
 
 
 
Blaine Everingham
Guest
Posts: n/a
 
      01-07-2004
Why don't you just use a split statement.... It woudl be faster then a rege
exp.


"hugo" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Seek xpath expression where an attribute name is a regular expression GIMME XML 3 12-29-2008 03:11 PM
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C++ 42 11-04-2008 12:39 PM
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C Programming 45 11-04-2008 12:39 PM
Matching abitrary expression in a regular expression =?iso-8859-1?B?bW9vcJk=?= Java 8 12-02-2005 12:51 AM
Dynamically changing the regular expression of Regular Expression validator VSK ASP .Net 2 08-24-2003 02:47 PM



Advertisments