regular expression

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • hugo

    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
    TAGxxTAGxxxxxxT AGxxxxxxxx

    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
  • Gunnar Hjalmarsson

    #2
    Re: regular expression

    hugo wrote:[color=blue]
    > 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
    > TAGxxTAGxxxxxxT AGxxxxxxxx
    >
    > 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.[/color]

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

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

    Comment

    • Blaine Everingham

      #3
      Re: regular expression

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


      "hugo" <hugodogo@yahoo .com> wrote in message
      news:81faa37b.0 401061833.1b94c 475@posting.goo gle.com...[color=blue]
      > 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
      > TAGxxTAGxxxxxxT AGxxxxxxxx
      >
      > 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[/color]


      Comment

      Working...