Does this match any number or just single digit ones?

Discussion in 'Perl Misc' started by Thomas Andersson, Aug 6, 2010.

  1. Will this line update $page with a number if it's double digit (ie 10+) or
    does the code need to change?

    my ($page) = $page_number_txt =~ /PAGE (\d) >/;
    Thomas Andersson, Aug 6, 2010
    #1
    1. Advertising

  2. Tad McClellan wrote:
    > Thomas Andersson <> wrote:
    >> Will this line update $page with a number if it's double digit (ie
    >> 10+) or does the code need to change?
    >>
    >> my ($page) = $page_number_txt =~ /PAGE (\d) >/;

    >
    > What happened when you tried it?


    It's sorted now, basically my script processed pages and a had a function to
    look for next page to see if it should continue. When page 10 came around it
    bugged out as it found a page, but pagenumber was incorrectly set. Changing
    to \d+ fixed it.
    Thomas Andersson, Aug 8, 2010
    #2
    1. Advertising

  3. Thomas Andersson

    Dr.Ruud Guest

    Thomas Andersson wrote:

    > Will this line update $page with a number if it's double digit (ie 10+) or
    > does the code need to change?
    >
    > my ($page) = $page_number_txt =~ /PAGE (\d) >/;


    Also, be aware that \d is not the same as [0-9].


    There are over 200 digit code points, see the output of:

    perl -CO -we '$| = 1;
    my $i;
    $SIG{__WARN__} = sub{ die "$i:$_[0]" };
    eval{ chr() || 1 }
    and chr() =~ /\d/
    and printf qq{%3s: %c [%x]\n}, ++$i, ($_)x2
    for 0 .. 0x1FFFD
    ' 2>&1 |less

    --
    Ruud
    Dr.Ruud, Aug 14, 2010
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fangs
    Replies:
    3
    Views:
    9,782
    darshana
    Oct 26, 2008
  2. championsleeper
    Replies:
    6
    Views:
    1,003
    championsleeper
    Apr 6, 2004
  3. Steven
    Replies:
    8
    Views:
    466
    Arndt Jonasson
    Feb 3, 2006
  4. Alex Vinokur
    Replies:
    1
    Views:
    260
    Alex Vinokur
    Aug 12, 2008
  5. Henry J.
    Replies:
    16
    Views:
    282
    Peter J. Holzer
    Oct 8, 2008
Loading...

Share This Page