summary refs log tree commit diff stats
path: root/tests/tregex.nim
blob: d9d22d6038bb098684527e418df8e81818d70711 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Test the new regular expression module
# which is based on the PCRE library

import
  regexprs

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

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

#OUT key: keyAYes!