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

Re: Thanks for your post

Expand Messages
  • Victor Bouffier
    Hi Ian, Sure, no problem. I m glad it worked for you. Regexes are extremely powerful tools. You can do pattern matching or for *not* matching, which is what
    Message 1 of 1 , Feb 25, 2006
      Hi Ian,
      Sure, no problem. I'm glad it worked for you.

      Regexes are extremely powerful tools. You can do pattern matching or for
      *not* matching, which is what the '(?!' grouping operator is all about.
      You can find all of the alternatives Perl offers in the following perdoc
      documents:

      Tutorials:
      perlrequick - Perl regular expressions quick start
      perlretut - Perl regular expressions tutorial

      Language Reference:
      perlre - Perl regular expressions
      perlreref - Perl Regular Expressions Reference

      Look into the tutorial (perlretut) for an explanation on how to use this
      and other regex operators. For a quick reference go into the last one
      (perlreref) and look into EXTENDED CONSTRUCTS.

      Best of luck.
      Victor


      On Sat, 2006-02-25 at 10:39 -0500, Ian Noble wrote:
      > Victor,
      >
      >
      >
      > Thanks for your post on the Yahoo Perl beginner email group!
      > This code will help me with another problem I was having filtering
      > messages. I was trying to somehow put a NOT condition in my regular
      > expression and the function you posed used (?!\d). I didn’t know this
      > was possible. Thanks again!
      >
      >
      >
      > > There is a great recipe from the Perl Cookbook to do just that. The
      >
      > > script is the following:
      >
      > >
      >
      > > sub commify {
      >
      > > my $text = reverse @_[0];
      >
      > > $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
      >
      > > return scalar reverse $text;
      >
      > > }
      >
      > >
      >
      > > To use it:
      >
      > >
      >
      > > print commify(1234567)
      >
      > > 1,234,567
      >
      > >
      >
      >
      >
      > Ian Noble
      > ian@...
      >
      > Noble Vision, INC.
      > Mobile: 804.937.8785
      >
      >
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.