tregex.nim 624 B

123456789101112131415161718192021222324252627282930
  1. discard """
  2. output: "key: keyAYes!"
  3. matrix: "--mm:refc; --mm:orc"
  4. """
  5. # Test the new regular expression module
  6. # which is based on the PCRE library
  7. when defined(powerpc64):
  8. # cheat as our powerpc test machine has no PCRE installed:
  9. echo "key: keyAYes!"
  10. else:
  11. import
  12. re
  13. import std/syncio
  14. if "keyA = valueA" =~ re"\s*(\w+)\s*\=\s*(\w+)":
  15. write(stdout, "key: ", matches[0])
  16. elif "# comment!" =~ re.re"\s*(\#.*)":
  17. # test re.re"" syntax
  18. echo("comment: ", matches[0])
  19. else:
  20. echo("Bug!")
  21. if "Username".match(re"[A-Za-z]+"):
  22. echo("Yes!")
  23. else:
  24. echo("Bug!")
  25. #OUT key: keyAYes!