regular expression

Discussion in 'Perl' started by hugo, Jan 7, 2004.

  1. hugo

    hugo Guest

    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
     
    hugo, Jan 7, 2004
    #1
    1. Advertising

  2. 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
     
    Gunnar Hjalmarsson, Jan 7, 2004
    #2
    1. Advertising

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


    "hugo" <> wrote in message
    news:...
    > 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
     
    Blaine Everingham, Jan 7, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Keith-Earl
    Replies:
    1
    Views:
    475
    Mary Chipman
    Jun 15, 2004
  2. VSK
    Replies:
    2
    Views:
    2,390
  3. =?iso-8859-1?B?bW9vcJk=?=

    Matching abitrary expression in a regular expression

    =?iso-8859-1?B?bW9vcJk=?=, Dec 1, 2005, in forum: Java
    Replies:
    8
    Views:
    884
    Alan Moore
    Dec 2, 2005
  4. GIMME
    Replies:
    3
    Views:
    12,050
    vforvikash
    Dec 29, 2008
  5. Noman Shapiro
    Replies:
    0
    Views:
    258
    Noman Shapiro
    Jul 17, 2013
Loading...

Share This Page