Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Does this match any number or just single digit ones?

Reply
Thread Tools

Does this match any number or just single digit ones?

 
 
Thomas Andersson
Guest
Posts: n/a
 
      08-06-2010
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) >/;


 
Reply With Quote
 
 
 
 
Thomas Andersson
Guest
Posts: n/a
 
      08-08-2010
Tad McClellan wrote:
> Thomas Andersson <(E-Mail Removed)> 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.


 
Reply With Quote
 
 
 
 
Dr.Ruud
Guest
Posts: n/a
 
      08-14-2010
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
(8-bit binary to two digit bcd) or (8-bit binary to two digit seven segment) Fangs VHDL 3 10-26-2008 06:41 AM
convert single digit to two digits ofuuzo1@yahoo.no XML 2 04-12-2008 01:02 PM
Need help identifying a virus - single digit graphic floats "on-top" of screen mrf Computer Support 2 10-25-2006 01:57 AM
find digit length or the number of numbers in number ? Steven C Programming 8 02-03-2006 04:21 PM
match three digit number using regular expression championsleeper Perl 6 04-06-2004 08:54 PM



Advertisments