News for hackers. Stuff that matters.
Re:\d less efficient than [0-9] by rwmj on Sunday May 19, 2013 @06:06PM (#5734600)
I was a bit surprised that Perl does not seem to be matching Unicode digits. Anyone know why?

    $ echo '0' | perl -pe 'print "yes: " if m/\d/'
    yes: 0
    $ echo '੧' | perl -pe 'print "yes: " if m/\d/'
    ੧
Re:\d less efficient than [0-9] by xonea on Sunday May 19, 2013 @06:19PM (#5734641)
You have to tell perl to expect utf8 from stdin (switch -C).

  $ echo '੧' | perl -C -pe 'print "yes: " if m/\d/'
  and
  $ perl -e 'use utf8; print "yes\n" if "੧" =~ m/\d/;'
both work :)
Re:\d less efficient than [0-9] by pooriaazimi on Sunday May 19, 2013 @06:24PM (#5734650)
`man perlunicode` is chockfull of utf8-related stuff (and it's looong): http://perldoc.perl.org/5.14.0/perlunicode.html
Re:\d less efficient than [0-9] by damncabbage on Sunday May 19, 2013 @07:56PM (#5734987)
Ditto PHP:

  php > var_export(preg_match("/\d/", "1"));
  1
  php > var_export(preg_match("/\d/", "۳"));
  0
Re:\d less efficient than [0-9] by jpiasetz on Sunday May 19, 2013 @08:31PM (#5735130)
Add /u

    php > var_export(preg_match("/\d/u", "۳"));
Re:\d less efficient than [0-9] by bellbind on Sunday May 19, 2013 @06:17PM (#5734631)
Re:\d less efficient than [0-9] by ars on Sunday May 19, 2013 @06:17PM (#5734630)
Try:

    utf8::upgrade($string)
And/or:

    use feature 'unicode_strings'
Re:\d less efficient than [0-9] by netfeed on Monday May 20, 2013 @08:30AM (#5737276)
The documentation says \d should match if you use /u on the regex