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

how to chose the word from this sentence?

Expand Messages
  • Lim
    hi all. phase: v(out)=(7.3124dB,-82.9127) at 992.174 i have this word out from the simulation. If i wan choose only -82.9127 this number from the above
    Message 1 of 8 , Apr 9, 2012
    • 0 Attachment
      hi all.

      phase: v(out)=(7.3124dB,-82.9127) at 992.174

      i have this word out from the simulation. If i wan choose only -82.9127 this number from the above statement. How should i write it ?

      Regards,
      Lim
    • timothy adigun
      Hi Lim, ... #!/usr/bin/perl use warnings; use strict; my $w= phase: v(out)=(7.3124dB,-82.9127) at 992.174 ; $w=~/.+(-.+) ).+/; print $1; **OUTPUT** -82.9127
      Message 2 of 8 , Apr 9, 2012
      • 0 Attachment
        Hi Lim,

        On Tue, Apr 10, 2012 at 4:57 AM, Lim <lim.weijer@...> wrote:

        > **
        >
        >
        > hi all.
        >
        > phase: v(out)=(7.3124dB,-82.9127) at 992.174
        >
        > i have this word out from the simulation. If i wan choose only -82.9127
        > this number from the above statement. How should i write it ?
        >
        > This is one way of doing it:

        #!/usr/bin/perl
        use warnings;
        use strict;

        my $w='phase: v(out)=(7.3124dB,-82.9127) at 992.174';
        $w=~/.+(-.+)\).+/;
        print $1;

        **OUTPUT**
        -82.9127

        > Regards,
        > Lim
        >
        >
        >



        --
        Tim


        [Non-text portions of this message have been removed]
      • Matthew K
        ... Great idea using a regex; I would also use that for this problem. Not intending to cause problems, but I think there might be a small problem in what you
        Message 3 of 8 , Apr 10, 2012
        • 0 Attachment
          > #!/usr/bin/perl

          > use warnings;
          > use strict;
          >
          >   my $w='phase: v(out)=(7.3124dB,-82.9127) at 992.174';
          >     $w=~/.+(-.+)\).+/;
          >   print $1;
          >
          > **OUTPUT**
          > -82.9127
          >
          > --
          > Tim


          -------------------------------------------------------------------------



          Great idea using a regex; I would also use that for this problem. Not intending to cause problems, but I think there might be a small problem in what you gave him though. That regex will work for this particular number, but the regex you gave him will not work on positive numbers, or if there are ever characters after it like the first number. I might use something like this.

          $w =~ \(.+?,(-?[\d,\.]+)[a-zA-Z]*\);

           
          ----
          Matt
        • Lim
          ... Thanks Tim and Matt It is very helpfull to me. best regards, LIM
          Message 4 of 8 , Apr 10, 2012
          • 0 Attachment
            --- In perl-beginner@yahoogroups.com, Matthew K <matt_hew@...> wrote:
            >
            > > #!/usr/bin/perl
            >
            > > use warnings;
            > > use strict;
            > >
            > >   my $w='phase: v(out)=(7.3124dB,-82.9127) at 992.174';
            > >     $w=~/.+(-.+)\).+/;
            > >   print $1;
            > >
            > > **OUTPUT**
            > > -82.9127
            > >
            > > --
            > > Tim
            >
            >
            > -------------------------------------------------------------------------
            >
            >
            >
            > Great idea using a regex; I would also use that for this problem. Not intending to cause problems, but I think there might be a small problem in what you gave him though. That regex will work for this particular number, but the regex you gave him will not work on positive numbers, or if there are ever characters after it like the first number. I might use something like this.
            >
            > $w =~ \(.+?,(-?[\d,\.]+)[a-zA-Z]*\);
            >
            >  
            > ----
            > Matt
            >


            Thanks Tim and Matt
            It is very helpfull to me.

            best regards,
            LIM
          • timothy adigun
            Hi Matthew, ... I don t think you are causing any problems, you are just bringing a wonderful idea to the fore. However, the regex you gave will crash on use
            Message 5 of 8 , Apr 10, 2012
            • 0 Attachment
              Hi Matthew,

              On Tue, Apr 10, 2012 at 3:52 PM, Matthew K <matt_hew@...> wrote:

              > **
              >
              >
              > > #!/usr/bin/perl
              >
              > > use warnings;
              > > use strict;
              > >
              > > my $w='phase: v(out)=(7.3124dB,-82.9127) at 992.174';
              > > $w=~/.+(-.+)\).+/;
              > > print $1;
              > >
              > > **OUTPUT**
              > > -82.9127
              > >
              > > --
              > > Tim
              >
              > ----------------------------------------------------------
              >
              > Great idea using a regex; I would also use that for this problem. Not
              > intending to cause problems, but I think there might be a small problem in
              > what you gave him though. That regex will work for this particular number,
              > but the regex you gave him will not work on positive numbers, or if there
              > are ever characters after it like the first number. I might use something
              > like this.
              >

              I don't think you are "causing" any problems, you are just bringing a
              wonderful idea to the fore. However, the regex you gave will crash on use
              of ?PATTERN? syntax error. Check it yourself.

              >
              > $w =~ \(.+?,(-?[\d,\.]+)[a-zA-Z]*\);
              >

              I believe what you want to write is:
              $w =~ /\(.+?,(-?[\d,\.]+)[a-zA-Z]*\)/;

              Moreover, to address the issues you raised, all you need do is this:
              $w=~/.+,(-?.+)\).+/;

              >
              >
              > ----
              > Matt
              >
              >
              >



              --
              Tim


              [Non-text portions of this message have been removed]
            • Lee Marlin
              Hi,   There s an extra space in the code that caused the earlier example to fail. Old Version: $w=~/.+(-.+) ).+/;   This produces NO OUTPUT !   Instead,
              Message 6 of 8 , Apr 10, 2012
              • 0 Attachment
                Hi,
                 
                There's an extra space in the code that caused the earlier example to fail.
                Old Version: $w=~/.+(-.+) \).+/;
                 
                This produces NO OUTPUT !
                 
                Instead, change it to:
                 
                New Version: $w=~/.+(-.+)\).+/;
                 
                Making this change causes the ouput to be: -82.9127
                 
                Lee Marlin

                [Non-text portions of this message have been removed]
              • merlyn@stonehenge.com
                ************************************************** * * THIS IS NOT THE OFFICIAL perl BEGINNERS GROUP. * * The official one is at beginners@perl.org, with
                Message 7 of 8 , Apr 10, 2012
                • 0 Attachment
                  **************************************************
                  *
                  * THIS IS NOT THE OFFICIAL perl BEGINNERS GROUP.
                  *
                  * The official one is at beginners@..., with instructions on how to
                  * join at http://lists.perl.org/list/beginners.html.
                  *
                  * You'll get far better response there, not to say you won't get *any* here.
                  *
                  **************************************************

                  --
                  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.posterous.com/ for Smalltalk discussion
                • Lim
                  ... Thanks for the suggestion website. Regards, LIM
                  Message 8 of 8 , Apr 11, 2012
                  • 0 Attachment
                    --- In perl-beginner@yahoogroups.com, merlyn@... wrote:
                    >
                    >
                    > **************************************************
                    > *
                    > * THIS IS NOT THE OFFICIAL perl BEGINNERS GROUP.
                    > *
                    > * The official one is at beginners@..., with instructions on how to
                    > * join at http://lists.perl.org/list/beginners.html.
                    > *
                    > * You'll get far better response there, not to say you won't get *any* here.
                    > *
                    > **************************************************
                    >
                    > --
                    > 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.posterous.com/ for Smalltalk discussion
                    >


                    Thanks for the suggestion website.

                    Regards,
                    LIM
                  Your message has been successfully submitted and would be delivered to recipients shortly.