tregex.nim 592 B

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