fork download
  1. #!/usr/bin/env perl
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. while (<DATA>) {
  7.  
  8. # A1 => An integer between 1 and 99, without leading zeros.
  9. # (Although zero can appear by itself.)
  10. #
  11. # A2 => A optional fractional component that may contain no more
  12. # than two digits.
  13. #
  14. # -OR-
  15. #
  16. # B1 => The integer 100.
  17. #
  18. # B2 => A optional fractional component following that may
  19. # consist of one or two zeros only.
  20. #
  21.  
  22. if (/^(?:(?:[0-9]|[1-9]{1,2})(?:,[0-9]{1,2})?|(?:100)(?:,0{1,2})?)$/) {
  23. # ^^^^^^^^A1^^^^^^ ^^^^^A2^^^^ ^B1 ^^^B2^^
  24.  
  25. print "* [$_]\n";
  26. } else {
  27. print " [$_]\n";
  28. }
  29. }
  30.  
  31. __DATA__
  32. 0
  33. 01
  34. 11
  35. 99
  36. 100
  37. 101
  38. 0,0
  39. 0,00
  40. 01,00
  41. 0,000
  42. 99,00
  43. 99,99
  44. 100,0
  45. 100,00
  46. 100,000
  47. 100,01
  48. 100,99
  49. 101,00
  50.  
Success #stdin #stdout 0s 3696KB
stdin
Standard input is empty
stdout
* [0]
  [01]
* [11]
* [99]
* [100]
  [101]
* [0,0]
* [0,00]
  [01,00]
  [0,000]
* [99,00]
* [99,99]
* [100,0]
* [100,00]
  [100,000]
  [100,01]
  [100,99]
  [101,00]