summary refs log tree commit diff stats
path: root/tests/accept/run/tregex.nim
blob: 7ac628c4dd9d24bba9687f7fbaa8adefd6740850 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
discard """
  file: "tregex.nim"
  output: "key: keyAYes!"
"""
# Test the new regular expression module
# which is based on the PCRE library

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!