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

Re: [PBML] Can a substitute self-reference?

Expand Messages
  • Thiago Nascimento
    Another regex is: $string =~ s/^ D*( d.* d) D*$/$1/; ... -- Thiago Nascimento perl -e $_= tMM naaCt Feocmama_itpUilucoGa ;$_.=$1,print $2 while
    Message 1 of 13 , Jul 8 5:33 AM
    • 0 Attachment
      Another regex is:

      $string =~ s/^\D*(\d.*\d)\D*$/$1/;

      On Tue, Jul 8, 2008 at 9:31 AM, Amit Saxena <learn.tech123@...> wrote:

      > Hi
      >
      > Not sure whether my version is more efficient / better or not (comments
      > awaited) :-
      >
      >
      > [root@111 ~]# cat v.pl
      > #! /usr/bin/perl
      >
      > my $string = "array ( 101 => 11, 89 => 13, 88 => 6, 90 => 14, 120 => 1, )";
      >
      > print "\nstring is [$string]";
      >
      > # $string =~ s/array\s\(\s(.*),\s\)/$1/;
      > $string =~ s/^([^(]*\(\s+)(.*?)(,\s+\))$/\2/g;
      >
      > print "\nstring is [$string]";
      >
      > print "\nHave a nice day !\n";
      >
      > [root@111 ~]# perl v.pl
      >
      > string is [array ( 101 => 11, 89 => 13, 88 => 6, 90 => 14, 120 => 1, )]
      > string is [101 => 11, 89 => 13, 88 => 6, 90 => 14, 120 => 1]
      > Have a nice day !
      > [root@111 ~]#
      >
      > Regards,
      > Amit Saxena
      >
      > On Tue, Jul 8, 2008 at 5:46 PM, hooyar66 <pcbcad@...<pcbcad%40hotpop.com>>
      > wrote:
      >
      > > --- In perl-beginner@yahoogroups.com <perl-beginner%40yahoogroups.com><perl-beginner%
      > 40yahoogroups.com>,
      >
      > > "Amit Saxena"
      > >
      > > <learn.tech123@...> wrote:
      > > >
      > > > It's working at my end though it does not seems to be an efficient way,
      > > >
      > > > [root@111 ~]# cat v.pl
      > > > #! /usr/bin/perl
      > > >
      > > > my $string = "array ( 101 => 11, 89 => 13, 88 => 6, 90 => 14, 120 =>
      > > 1, )";
      > > >
      > > > print "\nstring is [$string]";
      > > >
      > > > $string =~ s/array\s\(\s(.*),\s\)/$1/;
      > > >
      > > > print "\nstring is [$string]";
      > > >
      > > > print "\nHave a nice day !\n";
      > > >
      > > > [root@111 ~]# perl v.pl
      > > >
      > > > string is [array ( 101 => 11, 89 => 13, 88 => 6, 90 => 14, 120 => 1, )]
      > > > string is [101 => 11, 89 => 13, 88 => 6, 90 => 14, 120 => 1]
      > > > Have a nice day !
      > > > [root@111 ~]#
      > > >
      > > > Regards,
      > > > Amit Saxena
      > > >
      > > > On Tue, Jul 8, 2008 at 5:10 PM, hooyar66 <pcbcad@...> wrote:
      > > >
      > > > > I want to remove from the string below - "array ( " at the front and
      > > > > the ", )" at the end with a single substitute command.
      > > > >
      > > > > The following is what I have tried but doesn't work:
      > > > >
      > > > > my $string = "array ( 101 => 11, 89 => 13, 88 => 6, 90 => 14, 120 =>
      > > > > 1, )";
      > > > >
      > > > > $string =~ s/array\s\(\s(.*),\s\)/$1/;
      > > > >
      > > > > I can do it with a couple of line - one for each end, but I was
      > hoping
      > > > > it would be possible with one.
      > > > >
      > > > > Any help appreciated
      > > > >
      > > > > Thanks
      > > > > NJH
      > > > >
      > > > >
      > > > >
      > > >
      > > >
      > > > [Non-text portions of this message have been removed]
      > > >
      > >
      > > Very bizarre - it's not working for me: WIN XP, Activestate v5.8.8
      > >
      > > Can you recommend a more 'efficient way'?
      > >
      > > Thanks
      > >
      > >
      > >
      >
      > [Non-text portions of this message have been removed]
      >
      >
      >



      --
      Thiago Nascimento
      perl -e '$_="tMM naaCt Feocmama_itpUilucoGa";$_.=$1,print $2 while
      s/(..)(.)//;print substr$_,1,1;'
      "...just because I don't know the meaning of my art, does not mean it has no
      meaning..." S.D.


      [Non-text portions of this message have been removed]
    • hooyar66
      ... (comments ... = 1, ) ; ... 1, )] ... ...
      Message 2 of 13 , Jul 8 6:01 AM
      • 0 Attachment
        --- In perl-beginner@yahoogroups.com, "Thiago Nascimento"
        <nascimenthiago@...> wrote:
        >
        > Another regex is:
        >
        > $string =~ s/^\D*(\d.*\d)\D*$/$1/;
        >
        > On Tue, Jul 8, 2008 at 9:31 AM, Amit Saxena <learn.tech123@...> wrote:
        >
        > > Hi
        > >
        > > Not sure whether my version is more efficient / better or not
        (comments
        > > awaited) :-
        > >
        > >
        > > [root@111 ~]# cat v.pl
        > > #! /usr/bin/perl
        > >
        > > my $string = "array ( 101 => 11, 89 => 13, 88 => 6, 90 => 14, 120
        => 1, )";
        > >
        > > print "\nstring is [$string]";
        > >
        > > # $string =~ s/array\s\(\s(.*),\s\)/$1/;
        > > $string =~ s/^([^(]*\(\s+)(.*?)(,\s+\))$/\2/g;
        > >
        > > print "\nstring is [$string]";
        > >
        > > print "\nHave a nice day !\n";
        > >
        > > [root@111 ~]# perl v.pl
        > >
        > > string is [array ( 101 => 11, 89 => 13, 88 => 6, 90 => 14, 120 =>
        1, )]
        > > string is [101 => 11, 89 => 13, 88 => 6, 90 => 14, 120 => 1]
        > > Have a nice day !
        > > [root@111 ~]#
        > >
        > > Regards,
        > > Amit Saxena
        > >
        > > On Tue, Jul 8, 2008 at 5:46 PM, hooyar66
        <pcbcad@...<pcbcad%40hotpop.com>>
        > > wrote:
        > >
        > > > --- In perl-beginner@yahoogroups.com
        <perl-beginner%40yahoogroups.com><perl-beginner%
        > > 40yahoogroups.com>,
        > >
        > > > "Amit Saxena"
        > > >
        > > > <learn.tech123@> wrote:
        > > > >
        > > > > It's working at my end though it does not seems to be an
        efficient way,
        > > > >
        > > > > [root@111 ~]# cat v.pl
        > > > > #! /usr/bin/perl
        > > > >
        > > > > my $string = "array ( 101 => 11, 89 => 13, 88 => 6, 90 => 14,
        120 =>
        > > > 1, )";
        > > > >
        > > > > print "\nstring is [$string]";
        > > > >
        > > > > $string =~ s/array\s\(\s(.*),\s\)/$1/;
        > > > >
        > > > > print "\nstring is [$string]";
        > > > >
        > > > > print "\nHave a nice day !\n";
        > > > >
        > > > > [root@111 ~]# perl v.pl
        > > > >
        > > > > string is [array ( 101 => 11, 89 => 13, 88 => 6, 90 => 14, 120
        => 1, )]
        > > > > string is [101 => 11, 89 => 13, 88 => 6, 90 => 14, 120 => 1]
        > > > > Have a nice day !
        > > > > [root@111 ~]#
        > > > >
        > > > > Regards,
        > > > > Amit Saxena
        > > > >
        > > > > On Tue, Jul 8, 2008 at 5:10 PM, hooyar66 <pcbcad@> wrote:
        > > > >
        > > > > > I want to remove from the string below - "array ( " at the
        front and
        > > > > > the ", )" at the end with a single substitute command.
        > > > > >
        > > > > > The following is what I have tried but doesn't work:
        > > > > >
        > > > > > my $string = "array ( 101 => 11, 89 => 13, 88 => 6, 90 =>
        14, 120 =>
        > > > > > 1, )";
        > > > > >
        > > > > > $string =~ s/array\s\(\s(.*),\s\)/$1/;
        > > > > >
        > > > > > I can do it with a couple of line - one for each end, but I was
        > > hoping
        > > > > > it would be possible with one.
        > > > > >
        > > > > > Any help appreciated
        > > > > >
        > > > > > Thanks
        > > > > > NJH
        > > > > >
        > > > > >
        > > > > >
        > > > >
        > > > >
        > > > > [Non-text portions of this message have been removed]
        > > > >
        > > >
        > > > Very bizarre - it's not working for me: WIN XP, Activestate v5.8.8
        > > >
        > > > Can you recommend a more 'efficient way'?
        > > >
        > > > Thanks
        > > >
        > > >
        > > >
        > >
        > > [Non-text portions of this message have been removed]
        > >
        > >
        > >
        >
        >
        >
        > --
        > Thiago Nascimento
        > perl -e '$_="tMM naaCt Feocmama_itpUilucoGa";$_.=$1,print $2 while
        > s/(..)(.)//;print substr$_,1,1;'
        > "...just because I don't know the meaning of my art, does not mean
        it has no
        > meaning..." S.D.
        >
        >
        > [Non-text portions of this message have been removed]
        >

        Thanks Thiago - I like! Seems my 'solution replication' problem is
        elsewhere....
      • hooyar66
        ... I was ... OK I ve isolated my problem - I really would appreciate some help understanding what the problem is. My String (each character in square
        Message 3 of 13 , Jul 8 7:05 AM
        • 0 Attachment
          --- In perl-beginner@yahoogroups.com, "hooyar66" <pcbcad@...> wrote:
          >
          > --- In perl-beginner@yahoogroups.com, "Thiago Nascimento"
          > <nascimenthiago@> wrote:
          > >
          > > Another regex is:
          > >
          > > $string =~ s/^\D*(\d.*\d)\D*$/$1/;
          > >
          > > On Tue, Jul 8, 2008 at 9:31 AM, Amit Saxena <learn.tech123@> wrote:
          > >
          > > > Hi
          > > >
          > > > Not sure whether my version is more efficient / better or not
          > (comments
          > > > awaited) :-
          > > >
          > > >
          > > > [root@111 ~]# cat v.pl
          > > > #! /usr/bin/perl
          > > >
          > > > my $string = "array ( 101 => 11, 89 => 13, 88 => 6, 90 => 14, 120
          > => 1, )";
          > > >
          > > > print "\nstring is [$string]";
          > > >
          > > > # $string =~ s/array\s\(\s(.*),\s\)/$1/;
          > > > $string =~ s/^([^(]*\(\s+)(.*?)(,\s+\))$/\2/g;
          > > >
          > > > print "\nstring is [$string]";
          > > >
          > > > print "\nHave a nice day !\n";
          > > >
          > > > [root@111 ~]# perl v.pl
          > > >
          > > > string is [array ( 101 => 11, 89 => 13, 88 => 6, 90 => 14, 120 =>
          > 1, )]
          > > > string is [101 => 11, 89 => 13, 88 => 6, 90 => 14, 120 => 1]
          > > > Have a nice day !
          > > > [root@111 ~]#
          > > >
          > > > Regards,
          > > > Amit Saxena
          > > >
          > > > On Tue, Jul 8, 2008 at 5:46 PM, hooyar66
          > <pcbcad@<pcbcad%40hotpop.com>>
          > > > wrote:
          > > >
          > > > > --- In perl-beginner@yahoogroups.com
          > <perl-beginner%40yahoogroups.com><perl-beginner%
          > > > 40yahoogroups.com>,
          > > >
          > > > > "Amit Saxena"
          > > > >
          > > > > <learn.tech123@> wrote:
          > > > > >
          > > > > > It's working at my end though it does not seems to be an
          > efficient way,
          > > > > >
          > > > > > [root@111 ~]# cat v.pl
          > > > > > #! /usr/bin/perl
          > > > > >
          > > > > > my $string = "array ( 101 => 11, 89 => 13, 88 => 6, 90 => 14,
          > 120 =>
          > > > > 1, )";
          > > > > >
          > > > > > print "\nstring is [$string]";
          > > > > >
          > > > > > $string =~ s/array\s\(\s(.*),\s\)/$1/;
          > > > > >
          > > > > > print "\nstring is [$string]";
          > > > > >
          > > > > > print "\nHave a nice day !\n";
          > > > > >
          > > > > > [root@111 ~]# perl v.pl
          > > > > >
          > > > > > string is [array ( 101 => 11, 89 => 13, 88 => 6, 90 => 14, 120
          > => 1, )]
          > > > > > string is [101 => 11, 89 => 13, 88 => 6, 90 => 14, 120 => 1]
          > > > > > Have a nice day !
          > > > > > [root@111 ~]#
          > > > > >
          > > > > > Regards,
          > > > > > Amit Saxena
          > > > > >
          > > > > > On Tue, Jul 8, 2008 at 5:10 PM, hooyar66 <pcbcad@> wrote:
          > > > > >
          > > > > > > I want to remove from the string below - "array ( " at the
          > front and
          > > > > > > the ", )" at the end with a single substitute command.
          > > > > > >
          > > > > > > The following is what I have tried but doesn't work:
          > > > > > >
          > > > > > > my $string = "array ( 101 => 11, 89 => 13, 88 => 6, 90 =>
          > 14, 120 =>
          > > > > > > 1, )";
          > > > > > >
          > > > > > > $string =~ s/array\s\(\s(.*),\s\)/$1/;
          > > > > > >
          > > > > > > I can do it with a couple of line - one for each end, but
          I was
          > > > hoping
          > > > > > > it would be possible with one.
          > > > > > >
          > > > > > > Any help appreciated
          > > > > > >
          > > > > > > Thanks
          > > > > > > NJH
          > > > > > >
          > > > > > >
          > > > > > >
          > > > > >
          > > > > >
          > > > > > [Non-text portions of this message have been removed]
          > > > > >
          > > > >
          > > > > Very bizarre - it's not working for me: WIN XP, Activestate v5.8.8
          > > > >
          > > > > Can you recommend a more 'efficient way'?
          > > > >
          > > > > Thanks
          > > > >
          > > > >
          > > > >
          > > >
          > > > [Non-text portions of this message have been removed]
          > > >
          > > >
          > > >
          > >
          > >
          > >
          > > --
          > > Thiago Nascimento
          > > perl -e '$_="tMM naaCt Feocmama_itpUilucoGa";$_.=$1,print $2 while
          > > s/(..)(.)//;print substr$_,1,1;'
          > > "...just because I don't know the meaning of my art, does not mean
          > it has no
          > > meaning..." S.D.
          > >
          > >
          > > [Non-text portions of this message have been removed]
          > >
          >
          > Thanks Thiago - I like! Seems my 'solution replication' problem is
          > elsewhere....
          >

          OK I've isolated my problem - I really would appreciate some help
          understanding what the problem is.

          My String (each character in square brackets) is really this, note the
          'extra' whitespace:

          [a][r][r][a][y][ ][(][ ][ ][ ][1][0][1][ ][=][>][ ][1][1][,][ ][ ][
          ][8][9][ ][=][>][ ][1][3][,][ ][ ][ ][8][8][ ][=][>][ ][6][,][ ][ ][
          ][9][0][ ][=][>][ ][1][4][,][ ][ ][ ][1][2][0][ ][=][>][ ][1][,][ ][)]

          If I use the following command:

          $return =~ s/(^\D*\d.*)/$1/;

          I get this:

          [a][r][r][a][y][ ][(][ ][ ][ ][1][0][1][ ][=][>][ ][1][1][,]

          Surely I ought to get the whole string as '.*' means any old junk?

          If I use the following command:

          $string =~ s/(^\D*\d.*\s*)/$1/;

          I get this:

          [a][r][r][a][y][ ][(][ ][ ][ ][1][0][1][ ][=][>][ ][1][1][,][ ][ ][ ]

          So the problem seems to be that '.*' has an issue with multiple
          whitespace... or something!
        • Amit Saxena
          Tell me, whether my solution is working or not ? Regards, Amit Saxena ... [Non-text portions of this message have been removed]
          Message 4 of 13 , Jul 8 7:46 AM
          • 0 Attachment
            Tell me, whether my solution is working or not ?

            Regards,
            Amit Saxena

            On Tue, Jul 8, 2008 at 7:35 PM, hooyar66 <pcbcad@...> wrote:

            > --- In perl-beginner@yahoogroups.com <perl-beginner%40yahoogroups.com>,
            > "hooyar66" <pcbcad@...> wrote:
            > >
            > > --- In perl-beginner@yahoogroups.com <perl-beginner%40yahoogroups.com>,
            > "Thiago Nascimento"
            > > <nascimenthiago@> wrote:
            > > >
            > > > Another regex is:
            > > >
            > > > $string =~ s/^\D*(\d.*\d)\D*$/$1/;
            > > >
            > > > On Tue, Jul 8, 2008 at 9:31 AM, Amit Saxena <learn.tech123@> wrote:
            > > >
            > > > > Hi
            > > > >
            > > > > Not sure whether my version is more efficient / better or not
            > > (comments
            > > > > awaited) :-
            > > > >
            > > > >
            > > > > [root@111 ~]# cat v.pl
            > > > > #! /usr/bin/perl
            > > > >
            > > > > my $string = "array ( 101 => 11, 89 => 13, 88 => 6, 90 => 14, 120
            > > => 1, )";
            > > > >
            > > > > print "\nstring is [$string]";
            > > > >
            > > > > # $string =~ s/array\s\(\s(.*),\s\)/$1/;
            > > > > $string =~ s/^([^(]*\(\s+)(.*?)(,\s+\))$/\2/g;
            > > > >
            > > > > print "\nstring is [$string]";
            > > > >
            > > > > print "\nHave a nice day !\n";
            > > > >
            > > > > [root@111 ~]# perl v.pl
            > > > >
            > > > > string is [array ( 101 => 11, 89 => 13, 88 => 6, 90 => 14, 120 =>
            > > 1, )]
            > > > > string is [101 => 11, 89 => 13, 88 => 6, 90 => 14, 120 => 1]
            > > > > Have a nice day !
            > > > > [root@111 ~]#
            > > > >
            > > > > Regards,
            > > > > Amit Saxena
            > > > >
            > > > > On Tue, Jul 8, 2008 at 5:46 PM, hooyar66
            > > <pcbcad@<pcbcad%40hotpop.com>>
            > > > > wrote:
            > > > >
            > > > > > --- In perl-beginner@yahoogroups.com<perl-beginner%40yahoogroups.com>
            > > <perl-beginner%40yahoogroups.com><perl-beginner%
            > > > > 40yahoogroups.com>,
            > > > >
            > > > > > "Amit Saxena"
            > > > > >
            > > > > > <learn.tech123@> wrote:
            > > > > > >
            > > > > > > It's working at my end though it does not seems to be an
            > > efficient way,
            > > > > > >
            > > > > > > [root@111 ~]# cat v.pl
            > > > > > > #! /usr/bin/perl
            > > > > > >
            > > > > > > my $string = "array ( 101 => 11, 89 => 13, 88 => 6, 90 => 14,
            > > 120 =>
            > > > > > 1, )";
            > > > > > >
            > > > > > > print "\nstring is [$string]";
            > > > > > >
            > > > > > > $string =~ s/array\s\(\s(.*),\s\)/$1/;
            > > > > > >
            > > > > > > print "\nstring is [$string]";
            > > > > > >
            > > > > > > print "\nHave a nice day !\n";
            > > > > > >
            > > > > > > [root@111 ~]# perl v.pl
            > > > > > >
            > > > > > > string is [array ( 101 => 11, 89 => 13, 88 => 6, 90 => 14, 120
            > > => 1, )]
            > > > > > > string is [101 => 11, 89 => 13, 88 => 6, 90 => 14, 120 => 1]
            > > > > > > Have a nice day !
            > > > > > > [root@111 ~]#
            > > > > > >
            > > > > > > Regards,
            > > > > > > Amit Saxena
            > > > > > >
            > > > > > > On Tue, Jul 8, 2008 at 5:10 PM, hooyar66 <pcbcad@> wrote:
            > > > > > >
            > > > > > > > I want to remove from the string below - "array ( " at the
            > > front and
            > > > > > > > the ", )" at the end with a single substitute command.
            > > > > > > >
            > > > > > > > The following is what I have tried but doesn't work:
            > > > > > > >
            > > > > > > > my $string = "array ( 101 => 11, 89 => 13, 88 => 6, 90 =>
            > > 14, 120 =>
            > > > > > > > 1, )";
            > > > > > > >
            > > > > > > > $string =~ s/array\s\(\s(.*),\s\)/$1/;
            > > > > > > >
            > > > > > > > I can do it with a couple of line - one for each end, but
            > I was
            > > > > hoping
            > > > > > > > it would be possible with one.
            > > > > > > >
            > > > > > > > Any help appreciated
            > > > > > > >
            > > > > > > > Thanks
            > > > > > > > NJH
            > > > > > > >
            > > > > > > >
            > > > > > > >
            > > > > > >
            > > > > > >
            > > > > > > [Non-text portions of this message have been removed]
            > > > > > >
            > > > > >
            > > > > > Very bizarre - it's not working for me: WIN XP, Activestate v5.8.8
            > > > > >
            > > > > > Can you recommend a more 'efficient way'?
            > > > > >
            > > > > > Thanks
            > > > > >
            > > > > >
            > > > > >
            > > > >
            > > > > [Non-text portions of this message have been removed]
            > > > >
            > > > >
            > > > >
            > > >
            > > >
            > > >
            > > > --
            > > > Thiago Nascimento
            > > > perl -e '$_="tMM naaCt Feocmama_itpUilucoGa";$_.=$1,print $2 while
            > > > s/(..)(.)//;print substr$_,1,1;'
            > > > "...just because I don't know the meaning of my art, does not mean
            > > it has no
            > > > meaning..." S.D.
            > > >
            > > >
            > > > [Non-text portions of this message have been removed]
            > > >
            > >
            > > Thanks Thiago - I like! Seems my 'solution replication' problem is
            > > elsewhere....
            > >
            >
            > OK I've isolated my problem - I really would appreciate some help
            > understanding what the problem is.
            >
            > My String (each character in square brackets) is really this, note the
            > 'extra' whitespace:
            >
            > [a][r][r][a][y][ ][(][ ][ ][ ][1][0][1][ ][=][>][ ][1][1][,][ ][ ][
            > ][8][9][ ][=][>][ ][1][3][,][ ][ ][ ][8][8][ ][=][>][ ][6][,][ ][ ][
            > ][9][0][ ][=][>][ ][1][4][,][ ][ ][ ][1][2][0][ ][=][>][ ][1][,][ ][)]
            >
            > If I use the following command:
            >
            > $return =~ s/(^\D*\d.*)/$1/;
            >
            > I get this:
            >
            > [a][r][r][a][y][ ][(][ ][ ][ ][1][0][1][ ][=][>][ ][1][1][,]
            >
            > Surely I ought to get the whole string as '.*' means any old junk?
            >
            > If I use the following command:
            >
            > $string =~ s/(^\D*\d.*\s*)/$1/;
            >
            > I get this:
            >
            > [a][r][r][a][y][ ][(][ ][ ][ ][1][0][1][ ][=][>][ ][1][1][,][ ][ ][ ]
            >
            > So the problem seems to be that '.*' has an issue with multiple
            > whitespace... or something!
            >
            >
            >


            [Non-text portions of this message have been removed]
          • hooyar66
            ... , ... , ... 14, 120 ... 120 = ...
            Message 5 of 13 , Jul 8 8:20 AM
            • 0 Attachment
              --- In perl-beginner@yahoogroups.com, "Amit Saxena"
              <learn.tech123@...> wrote:
              >
              > Tell me, whether my solution is working or not ?
              >
              > Regards,
              > Amit Saxena
              >
              > On Tue, Jul 8, 2008 at 7:35 PM, hooyar66 <pcbcad@...> wrote:
              >
              > > --- In perl-beginner@yahoogroups.com
              <perl-beginner%40yahoogroups.com>,
              > > "hooyar66" <pcbcad@> wrote:
              > > >
              > > > --- In perl-beginner@yahoogroups.com
              <perl-beginner%40yahoogroups.com>,
              > > "Thiago Nascimento"
              > > > <nascimenthiago@> wrote:
              > > > >
              > > > > Another regex is:
              > > > >
              > > > > $string =~ s/^\D*(\d.*\d)\D*$/$1/;
              > > > >
              > > > > On Tue, Jul 8, 2008 at 9:31 AM, Amit Saxena <learn.tech123@>
              wrote:
              > > > >
              > > > > > Hi
              > > > > >
              > > > > > Not sure whether my version is more efficient / better or not
              > > > (comments
              > > > > > awaited) :-
              > > > > >
              > > > > >
              > > > > > [root@111 ~]# cat v.pl
              > > > > > #! /usr/bin/perl
              > > > > >
              > > > > > my $string = "array ( 101 => 11, 89 => 13, 88 => 6, 90 =>
              14, 120
              > > > => 1, )";
              > > > > >
              > > > > > print "\nstring is [$string]";
              > > > > >
              > > > > > # $string =~ s/array\s\(\s(.*),\s\)/$1/;
              > > > > > $string =~ s/^([^(]*\(\s+)(.*?)(,\s+\))$/\2/g;
              > > > > >
              > > > > > print "\nstring is [$string]";
              > > > > >
              > > > > > print "\nHave a nice day !\n";
              > > > > >
              > > > > > [root@111 ~]# perl v.pl
              > > > > >
              > > > > > string is [array ( 101 => 11, 89 => 13, 88 => 6, 90 => 14,
              120 =>
              > > > 1, )]
              > > > > > string is [101 => 11, 89 => 13, 88 => 6, 90 => 14, 120 => 1]
              > > > > > Have a nice day !
              > > > > > [root@111 ~]#
              > > > > >
              > > > > > Regards,
              > > > > > Amit Saxena
              > > > > >
              > > > > > On Tue, Jul 8, 2008 at 5:46 PM, hooyar66
              > > > <pcbcad@<pcbcad%40hotpop.com>>
              > > > > > wrote:
              > > > > >
              > > > > > > --- In
              perl-beginner@yahoogroups.com<perl-beginner%40yahoogroups.com>
              > > > <perl-beginner%40yahoogroups.com><perl-beginner%
              > > > > > 40yahoogroups.com>,
              > > > > >
              > > > > > > "Amit Saxena"
              > > > > > >
              > > > > > > <learn.tech123@> wrote:
              > > > > > > >
              > > > > > > > It's working at my end though it does not seems to be an
              > > > efficient way,
              > > > > > > >
              > > > > > > > [root@111 ~]# cat v.pl
              > > > > > > > #! /usr/bin/perl
              > > > > > > >
              > > > > > > > my $string = "array ( 101 => 11, 89 => 13, 88 => 6, 90
              => 14,
              > > > 120 =>
              > > > > > > 1, )";
              > > > > > > >
              > > > > > > > print "\nstring is [$string]";
              > > > > > > >
              > > > > > > > $string =~ s/array\s\(\s(.*),\s\)/$1/;
              > > > > > > >
              > > > > > > > print "\nstring is [$string]";
              > > > > > > >
              > > > > > > > print "\nHave a nice day !\n";
              > > > > > > >
              > > > > > > > [root@111 ~]# perl v.pl
              > > > > > > >
              > > > > > > > string is [array ( 101 => 11, 89 => 13, 88 => 6, 90 =>
              14, 120
              > > > => 1, )]
              > > > > > > > string is [101 => 11, 89 => 13, 88 => 6, 90 => 14, 120 => 1]
              > > > > > > > Have a nice day !
              > > > > > > > [root@111 ~]#
              > > > > > > >
              > > > > > > > Regards,
              > > > > > > > Amit Saxena
              > > > > > > >
              > > > > > > > On Tue, Jul 8, 2008 at 5:10 PM, hooyar66 <pcbcad@> wrote:
              > > > > > > >
              > > > > > > > > I want to remove from the string below - "array ( " at the
              > > > front and
              > > > > > > > > the ", )" at the end with a single substitute command.
              > > > > > > > >
              > > > > > > > > The following is what I have tried but doesn't work:
              > > > > > > > >
              > > > > > > > > my $string = "array ( 101 => 11, 89 => 13, 88 => 6, 90 =>
              > > > 14, 120 =>
              > > > > > > > > 1, )";
              > > > > > > > >
              > > > > > > > > $string =~ s/array\s\(\s(.*),\s\)/$1/;
              > > > > > > > >
              > > > > > > > > I can do it with a couple of line - one for each end, but
              > > I was
              > > > > > hoping
              > > > > > > > > it would be possible with one.
              > > > > > > > >
              > > > > > > > > Any help appreciated
              > > > > > > > >
              > > > > > > > > Thanks
              > > > > > > > > NJH
              > > > > > > > >
              > > > > > > > >
              > > > > > > > >
              > > > > > > >
              > > > > > > >
              > > > > > > > [Non-text portions of this message have been removed]
              > > > > > > >
              > > > > > >
              > > > > > > Very bizarre - it's not working for me: WIN XP,
              Activestate v5.8.8
              > > > > > >
              > > > > > > Can you recommend a more 'efficient way'?
              > > > > > >
              > > > > > > Thanks
              > > > > > >
              > > > > > >
              > > > > > >
              > > > > >
              > > > > > [Non-text portions of this message have been removed]
              > > > > >
              > > > > >
              > > > > >
              > > > >
              > > > >
              > > > >
              > > > > --
              > > > > Thiago Nascimento
              > > > > perl -e '$_="tMM naaCt Feocmama_itpUilucoGa";$_.=$1,print $2 while
              > > > > s/(..)(.)//;print substr$_,1,1;'
              > > > > "...just because I don't know the meaning of my art, does not mean
              > > > it has no
              > > > > meaning..." S.D.
              > > > >
              > > > >
              > > > > [Non-text portions of this message have been removed]
              > > > >
              > > >
              > > > Thanks Thiago - I like! Seems my 'solution replication' problem is
              > > > elsewhere....
              > > >
              > >
              > > OK I've isolated my problem - I really would appreciate some help
              > > understanding what the problem is.
              > >
              > > My String (each character in square brackets) is really this, note the
              > > 'extra' whitespace:
              > >
              > > [a][r][r][a][y][ ][(][ ][ ][ ][1][0][1][ ][=][>][ ][1][1][,][ ][ ][
              > > ][8][9][ ][=][>][ ][1][3][,][ ][ ][ ][8][8][ ][=][>][ ][6][,][ ][ ][
              > > ][9][0][ ][=][>][ ][1][4][,][ ][ ][ ][1][2][0][ ][=][>][ ][1][,][ ][)]
              > >
              > > If I use the following command:
              > >
              > > $return =~ s/(^\D*\d.*)/$1/;
              > >
              > > I get this:
              > >
              > > [a][r][r][a][y][ ][(][ ][ ][ ][1][0][1][ ][=][>][ ][1][1][,]
              > >
              > > Surely I ought to get the whole string as '.*' means any old junk?
              > >
              > > If I use the following command:
              > >
              > > $string =~ s/(^\D*\d.*\s*)/$1/;
              > >
              > > I get this:
              > >
              > > [a][r][r][a][y][ ][(][ ][ ][ ][1][0][1][ ][=][>][ ][1][1][,][ ][ ][ ]
              > >
              > > So the problem seems to be that '.*' has an issue with multiple
              > > whitespace... or something!
              > >
              > >
              > >
              >
              >
              > [Non-text portions of this message have been removed]
              >


              Hi Amit

              Sorry - no neither your solution or Thiago's works with the text
              string I referred to in my last post i.e. with each char in [].

              ----
              [a][r][r][a][y][ ][(][ ][ ][ ][1][0][1][ ][=][>][ ][1][1][,][ ][ ][
              ][8][9][ ][=][>][ ][1][3][,][ ][ ][ ][8][8][ ][=][>][ ][6][,][ ][ ][
              ][9][0][ ][=][>][ ][1][4][,][ ][ ][ ][1][2][0][ ][=][>][ ][1][,][ ][)]
              ----

              Sorry to be a stickler but it's proper convention to 'bottom post' on
              threads.

              Thanks
              NJH
            • Amit Saxena
              Surprisingly, it s working at my end. So I think, there is some issues with configuration at your end. Regarding the whitespace issue, always use s+ or s*
              Message 6 of 13 , Jul 8 10:04 PM
              • 0 Attachment
                Surprisingly, it's working at my end.

                So I think, there is some issues with configuration at your end.

                Regarding the whitespace issue, always use \s+ or \s* and try to avoid the
                non-greedyness of "*" by replacing it with
                "*?"

                Regards
                Amit Saxena

                On Tue, Jul 8, 2008 at 8:50 PM, hooyar66 <pcbcad@...> wrote:

                > --- In perl-beginner@yahoogroups.com <perl-beginner%40yahoogroups.com>,
                > "Amit Saxena"
                >
                > <learn.tech123@...> wrote:
                > >
                > > Tell me, whether my solution is working or not ?
                > >
                > > Regards,
                > > Amit Saxena
                > >
                > > On Tue, Jul 8, 2008 at 7:35 PM, hooyar66 <pcbcad@...> wrote:
                > >
                > > > --- In perl-beginner@yahoogroups.com <perl-beginner%40yahoogroups.com>
                > <perl-beginner%40yahoogroups.com>,
                > > > "hooyar66" <pcbcad@> wrote:
                > > > >
                > > > > --- In perl-beginner@yahoogroups.com<perl-beginner%40yahoogroups.com>
                > <perl-beginner%40yahoogroups.com>,
                >
                > > > "Thiago Nascimento"
                > > > > <nascimenthiago@> wrote:
                > > > > >
                > > > > > Another regex is:
                > > > > >
                > > > > > $string =~ s/^\D*(\d.*\d)\D*$/$1/;
                > > > > >
                > > > > > On Tue, Jul 8, 2008 at 9:31 AM, Amit Saxena <learn.tech123@>
                > wrote:
                > > > > >
                > > > > > > Hi
                > > > > > >
                > > > > > > Not sure whether my version is more efficient / better or not
                > > > > (comments
                > > > > > > awaited) :-
                > > > > > >
                > > > > > >
                > > > > > > [root@111 ~]# cat v.pl
                > > > > > > #! /usr/bin/perl
                > > > > > >
                > > > > > > my $string = "array ( 101 => 11, 89 => 13, 88 => 6, 90 =>
                > 14, 120
                > > > > => 1, )";
                > > > > > >
                > > > > > > print "\nstring is [$string]";
                > > > > > >
                > > > > > > # $string =~ s/array\s\(\s(.*),\s\)/$1/;
                > > > > > > $string =~ s/^([^(]*\(\s+)(.*?)(,\s+\))$/\2/g;
                > > > > > >
                > > > > > > print "\nstring is [$string]";
                > > > > > >
                > > > > > > print "\nHave a nice day !\n";
                > > > > > >
                > > > > > > [root@111 ~]# perl v.pl
                > > > > > >
                > > > > > > string is [array ( 101 => 11, 89 => 13, 88 => 6, 90 => 14,
                > 120 =>
                > > > > 1, )]
                > > > > > > string is [101 => 11, 89 => 13, 88 => 6, 90 => 14, 120 => 1]
                > > > > > > Have a nice day !
                > > > > > > [root@111 ~]#
                > > > > > >
                > > > > > > Regards,
                > > > > > > Amit Saxena
                > > > > > >
                > > > > > > On Tue, Jul 8, 2008 at 5:46 PM, hooyar66
                > > > > <pcbcad@<pcbcad%40hotpop.com>>
                > > > > > > wrote:
                > > > > > >
                > > > > > > > --- In
                > perl-beginner@yahoogroups.com <perl-beginner%40yahoogroups.com>
                > <perl-beginner%40yahoogroups.com>
                > > > > <perl-beginner%40yahoogroups.com><perl-beginner%
                > > > > > > 40yahoogroups.com>,
                > > > > > >
                > > > > > > > "Amit Saxena"
                > > > > > > >
                > > > > > > > <learn.tech123@> wrote:
                > > > > > > > >
                > > > > > > > > It's working at my end though it does not seems to be an
                > > > > efficient way,
                > > > > > > > >
                > > > > > > > > [root@111 ~]# cat v.pl
                > > > > > > > > #! /usr/bin/perl
                > > > > > > > >
                > > > > > > > > my $string = "array ( 101 => 11, 89 => 13, 88 => 6, 90
                > => 14,
                > > > > 120 =>
                > > > > > > > 1, )";
                > > > > > > > >
                > > > > > > > > print "\nstring is [$string]";
                > > > > > > > >
                > > > > > > > > $string =~ s/array\s\(\s(.*),\s\)/$1/;
                > > > > > > > >
                > > > > > > > > print "\nstring is [$string]";
                > > > > > > > >
                > > > > > > > > print "\nHave a nice day !\n";
                > > > > > > > >
                > > > > > > > > [root@111 ~]# perl v.pl
                > > > > > > > >
                > > > > > > > > string is [array ( 101 => 11, 89 => 13, 88 => 6, 90 =>
                > 14, 120
                > > > > => 1, )]
                > > > > > > > > string is [101 => 11, 89 => 13, 88 => 6, 90 => 14, 120 => 1]
                > > > > > > > > Have a nice day !
                > > > > > > > > [root@111 ~]#
                > > > > > > > >
                > > > > > > > > Regards,
                > > > > > > > > Amit Saxena
                > > > > > > > >
                > > > > > > > > On Tue, Jul 8, 2008 at 5:10 PM, hooyar66 <pcbcad@> wrote:
                > > > > > > > >
                > > > > > > > > > I want to remove from the string below - "array ( " at the
                > > > > front and
                > > > > > > > > > the ", )" at the end with a single substitute command.
                > > > > > > > > >
                > > > > > > > > > The following is what I have tried but doesn't work:
                > > > > > > > > >
                > > > > > > > > > my $string = "array ( 101 => 11, 89 => 13, 88 => 6, 90 =>
                > > > > 14, 120 =>
                > > > > > > > > > 1, )";
                > > > > > > > > >
                > > > > > > > > > $string =~ s/array\s\(\s(.*),\s\)/$1/;
                > > > > > > > > >
                > > > > > > > > > I can do it with a couple of line - one for each end, but
                > > > I was
                > > > > > > hoping
                > > > > > > > > > it would be possible with one.
                > > > > > > > > >
                > > > > > > > > > Any help appreciated
                > > > > > > > > >
                > > > > > > > > > Thanks
                > > > > > > > > > NJH
                > > > > > > > > >
                > > > > > > > > >
                > > > > > > > > >
                > > > > > > > >
                > > > > > > > >
                > > > > > > > > [Non-text portions of this message have been removed]
                > > > > > > > >
                > > > > > > >
                > > > > > > > Very bizarre - it's not working for me: WIN XP,
                > Activestate v5.8.8
                > > > > > > >
                > > > > > > > Can you recommend a more 'efficient way'?
                > > > > > > >
                > > > > > > > Thanks
                > > > > > > >
                > > > > > > >
                > > > > > > >
                > > > > > >
                > > > > > > [Non-text portions of this message have been removed]
                > > > > > >
                > > > > > >
                > > > > > >
                > > > > >
                > > > > >
                > > > > >
                > > > > > --
                > > > > > Thiago Nascimento
                > > > > > perl -e '$_="tMM naaCt Feocmama_itpUilucoGa";$_.=$1,print $2 while
                > > > > > s/(..)(.)//;print substr$_,1,1;'
                > > > > > "...just because I don't know the meaning of my art, does not mean
                > > > > it has no
                > > > > > meaning..." S.D.
                > > > > >
                > > > > >
                > > > > > [Non-text portions of this message have been removed]
                > > > > >
                > > > >
                > > > > Thanks Thiago - I like! Seems my 'solution replication' problem is
                > > > > elsewhere....
                > > > >
                > > >
                > > > OK I've isolated my problem - I really would appreciate some help
                > > > understanding what the problem is.
                > > >
                > > > My String (each character in square brackets) is really this, note the
                > > > 'extra' whitespace:
                > > >
                > > > [a][r][r][a][y][ ][(][ ][ ][ ][1][0][1][ ][=][>][ ][1][1][,][ ][ ][
                > > > ][8][9][ ][=][>][ ][1][3][,][ ][ ][ ][8][8][ ][=][>][ ][6][,][ ][ ][
                > > > ][9][0][ ][=][>][ ][1][4][,][ ][ ][ ][1][2][0][ ][=][>][ ][1][,][ ][)]
                > > >
                > > > If I use the following command:
                > > >
                > > > $return =~ s/(^\D*\d.*)/$1/;
                > > >
                > > > I get this:
                > > >
                > > > [a][r][r][a][y][ ][(][ ][ ][ ][1][0][1][ ][=][>][ ][1][1][,]
                > > >
                > > > Surely I ought to get the whole string as '.*' means any old junk?
                > > >
                > > > If I use the following command:
                > > >
                > > > $string =~ s/(^\D*\d.*\s*)/$1/;
                > > >
                > > > I get this:
                > > >
                > > > [a][r][r][a][y][ ][(][ ][ ][ ][1][0][1][ ][=][>][ ][1][1][,][ ][ ][ ]
                > > >
                > > > So the problem seems to be that '.*' has an issue with multiple
                > > > whitespace... or something!
                > > >
                > > >
                > > >
                > >
                > >
                > > [Non-text portions of this message have been removed]
                > >
                >
                > Hi Amit
                >
                > Sorry - no neither your solution or Thiago's works with the text
                > string I referred to in my last post i.e. with each char in [].
                >
                > ----
                > [a][r][r][a][y][ ][(][ ][ ][ ][1][0][1][ ][=][>][ ][1][1][,][ ][ ][
                > ][8][9][ ][=][>][ ][1][3][,][ ][ ][ ][8][8][ ][=][>][ ][6][,][ ][ ][
                > ][9][0][ ][=][>][ ][1][4][,][ ][ ][ ][1][2][0][ ][=][>][ ][1][,][ ][)]
                > ----
                >
                > Sorry to be a stickler but it's proper convention to 'bottom post' on
                > threads.
                >
                > Thanks
                > NJH
                >
                >
                >


                [Non-text portions of this message have been removed]
              • merlyn@stonehenge.com
                ... Amit Regarding the whitespace issue, always use s+ or s* and try to avoid the Amit non-greedyness of * by replacing it with Amit *? You mean avoid
                Message 7 of 13 , Jul 9 7:38 AM
                • 0 Attachment
                  >>>>> "Amit" == Amit Saxena <learn.tech123@...> writes:

                  Amit> Regarding the whitespace issue, always use \s+ or \s* and try to avoid the
                  Amit> non-greedyness of "*" by replacing it with
                  Amit> "*?"

                  You mean avoid the greediness? By default, * is greedy. *? is "lazy".

                  And I don't agree "in general". It's important to keep it in mind, but
                  it's not "automatically better".

                  --
                  Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
                  <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
                  Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
                  See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
                • Amit Saxena
                  Sorry about that typo, What I meant was :- Regarding the whitespace issue, always use s+ or s* and try to avoid the greedyness of * by replacing it with
                  Message 8 of 13 , Jul 9 7:50 AM
                  • 0 Attachment
                    Sorry about that typo,

                    What I meant was :-

                    Regarding the whitespace issue, always use \s+ or \s* and try to avoid the
                    greedyness of "*" by replacing it with "*?"


                    Regards,
                    Amit Saxena

                    On Wed, Jul 9, 2008 at 8:08 PM, <merlyn@...> wrote:

                    > >>>>> "Amit" == Amit Saxena <learn.tech123@...<learn.tech123%40gmail.com>>
                    > writes:
                    >
                    > Amit> Regarding the whitespace issue, always use \s+ or \s* and try to
                    > avoid the
                    > Amit> non-greedyness of "*" by replacing it with
                    > Amit> "*?"
                    >
                    > You mean avoid the greediness? By default, * is greedy. *? is "lazy".
                    >
                    > And I don't agree "in general". It's important to keep it in mind, but
                    > it's not "automatically better".
                    >
                    > --
                    > Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
                    > <merlyn@... <merlyn%40stonehenge.com>> <URL:
                    > http://www.stonehenge.com/merlyn/>
                    > Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
                    > See http://methodsandmessages.vox.com/ for Smalltalk and Seaside
                    > discussion
                    >
                    >


                    [Non-text portions of this message have been removed]
                  • Jenda Krynicky
                    From: Amit Saxena ... !post top- not Do what good is $str =~ s/^ s*?//; ? Do not try to avoid greedines ! Understand the
                    Message 9 of 13 , Jul 9 8:59 AM
                    • 0 Attachment
                      From: "Amit Saxena" <learn.tech123@...>
                      > Sorry about that typo,
                      >
                      > What I meant was :-
                      >
                      > Regarding the whitespace issue, always use \s+ or \s* and try to avoid the
                      > greedyness of "*" by replacing it with "*?"
                      >
                      > Regards,
                      > Amit Saxena

                      !post top- not Do

                      what good is
                      $str =~ s/^\s*?//;
                      ?

                      Do not "try to avoid greedines"! Understand the difference and choose
                      the right (greedy vs. lazy) version accordingly.

                      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.