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

Re: [PBML] how to chose the word from this sentence?

Expand Messages
  • 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 1 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 2 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 3 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 4 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.