Loading ...
Sorry, an error occurred while loading the content.

Array

Expand Messages
  • anil
    Hi All, $textmatter= sdfjsd fjgj fig1 jfbj fig1 fg hjhg tab1 djhdj tab2 asdjfj tab1 ; @array=$textmatter=~/ (fig[0-9]+|tab[0-9]+) /g; print @array ;
    Message 1 of 27 , Jan 11, 2008
    • 0 Attachment
      Hi All,

      $textmatter='sdfjsd fjgj "fig1" jfbj "fig1" fg hjhg "tab1"
      djhdj "tab2" asdjfj "tab1"';
      @array=$textmatter=~/"(fig[0-9]+|tab[0-9]+)"/g;
      print "@array";

      OUTPUT: fig1 fig1 tab1 tab2 tab1

      REQUIRED OUTPUT: fig1 tab1 tab2

      I need the first occurance of fig or tab details in the statment. How
      can i do this. Please suggest.
    • Jenda Krynicky
      From: anil ... You can t do that in the regexp. (Well ... you can, if you are very very cheaky. Unless the strings are
      Message 2 of 27 , Jan 11, 2008
      • 0 Attachment
        From: "anil" <n.selvakumar@...>
        > Hi All,
        >
        > $textmatter='sdfjsd fjgj "fig1" jfbj "fig1" fg hjhg "tab1"
        > djhdj "tab2" asdjfj "tab1"';
        > @array=$textmatter=~/"(fig[0-9]+|tab[0-9]+)"/g;
        > print "@array";
        >
        > OUTPUT: fig1 fig1 tab1 tab2 tab1
        >
        > REQUIRED OUTPUT: fig1 tab1 tab2
        >
        > I need the first occurance of fig or tab details in the statment. How
        > can i do this. Please suggest.

        You can't do that in the regexp. (Well ... you can, if you are very
        very cheaky. Unless the strings are really huge and contain lots of
        repeats I'd rather not go there.)

        You have to filter it later.

        See

        perldoc -q duplicate

        HTH, Jenda
        ===== Jenda@... === http://Jenda.Krynicky.cz =====
        When it comes to wine, women and song, wizards are allowed
        to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery
      Your message has been successfully submitted and would be delivered to recipients shortly.