hakonhagland

regex-utf8

May 6th, 2021
478
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package Foo;
  2. use strict;
  3. use warnings;
  4. use utf8;
  5. our %FORM = (placeString => "Región");
  6.  
  7. package main;
  8. use feature qw(say);
  9. use strict;
  10. use warnings;
  11. use utf8;
  12. binmode STDOUT, ':encoding(utf-8)';
  13. binmode STDERR, ':encoding(utf-8)';
  14.  
  15. my $placeString = $Foo::FORM{'placeString'};
  16. say STDOUT $placeString;
  17. printf "1: %vX\n", $placeString;
  18.  
  19. my $placeString2 = "Región";
  20. printf "2: %vX\n", $placeString2;
  21.  
  22. if ($placeString =~ /^([\w\s,.'-]+)$/) {
  23.     say STDERR "Accepted placename (1).";
  24. }
  25.  
  26. if ($placeString2 =~ /^([\w\s,.'-]+)$/) {
  27.     say STDERR "Accepted placename (2).";
  28. }
  29.  
RAW Paste Data