Last active
August 29, 2015 13:56
-
-
Save sbertrang/9040413 to your computer and use it in GitHub Desktop.
\d matches more than just digits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use open qw( :std :utf8 ); | |
# http://www.fileformat.info/info/unicode/char/06f3/index.htm | |
# Unicode Character 'EXTENDED ARABIC-INDIC DIGIT THREE' (U+06F3) | |
printf( STDOUT "%s: %s: * 1024 = %d\n", m!\A\d+\z! ? "num" : "nonum", $_, $_ * 1024 ) | |
for "1", "foo", "\x{6f3}" | |
; | |
__END__ | |
$ perl utf8num.pl | |
num: 1: * 1024 = 1024 | |
Argument "foo" isn't numeric in multiplication (*) at utf8num.pl line 8. | |
nonum: foo: * 1024 = 0 | |
Argument "\x{6f3}" isn't numeric in multiplication (*) at utf8num.pl line 8. | |
num: ۳: * 1024 = 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment