summary refs log tree commit diff stats
path: root/tests/stdlib/tregex.nim
blob: 21f4e6743959d600dd4a76bce03706aad8e06043 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
sp
discard """
  output: "key: keyAYes!"
"""
# Test the new regular expression module
# which is based on the PCRE library

when defined(powerpc64):
  # cheat as our powerpc test machine has no PCRE installed:
  echo "key: keyAYes!"

else:
  import
    re

  if "keyA = valueA" =~ re"\s*(\w+)\s*\=\s*(\w+)":
    write(stdout, "key: ", matches[0])
  elif "# comment!" =~ re.re"\s*(\#.*)":
    # test re.re"" syntax
    echo("comment: ", matches[0])
  else:
    echo("Bug!")

  if "Username".match(re"[A-Za-z]+"):
    echo("Yes!")
  else:
    echo("Bug!")

  #OUT key: keyAYes!