summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorDominik Picheta <dominikpicheta@googlemail.com>2017-10-20 20:43:34 +0100
committerAndreas Rumpf <rumpf_a@web.de>2017-10-20 21:43:34 +0200
commitaa96343f1dd7e78c43fe7a4e7761e05dba2b4411 (patch)
tree32000fea2f28ec1e8502b8864f0bd5ffb9db6a01 /lib
parentbfae7bfe8335267bd5d84b5b252382b5321d7c6d (diff)
downloadNim-aa96343f1dd7e78c43fe7a4e7761e05dba2b4411.tar.gz
Remove reExtended from re constructor. Fixes #5627. (#6514)
* Remove reExtended from re constructor. Fixes #5627.

* Implement `rex` procedure as requested by @Araq.
Diffstat (limited to 'lib')
-rw-r--r--lib/impure/re.nim13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/impure/re.nim b/lib/impure/re.nim
index e00f91de1..24fc83366 100644
--- a/lib/impure/re.nim
+++ b/lib/impure/re.nim
@@ -13,10 +13,6 @@
 ## We had to de-deprecate this module since too much code relies on it
 ## and many people prefer its API over ``nre``'s.
 ##
-## **Note:** The 're' proc defaults to the **extended regular expression
-## syntax** which lets you use whitespace freely to make your regexes readable.
-## However, this means matching whitespace requires ``\s`` or something similar.
-##
 ## This module is implemented by providing a wrapper around the
 ## `PRCE (Perl-Compatible Regular Expressions) <http://www.pcre.org>`_
 ## C library. This means that your application will depend on the PRCE
@@ -78,7 +74,7 @@ proc finalizeRegEx(x: Regex) =
   if not isNil(x.e):
     pcre.free_substring(cast[cstring](x.e))
 
-proc re*(s: string, flags = {reExtended, reStudy}): Regex =
+proc re*(s: string, flags = {reStudy}): Regex =
   ## Constructor of regular expressions.
   ##
   ## Note that Nim's
@@ -96,6 +92,13 @@ proc re*(s: string, flags = {reExtended, reStudy}): Regex =
     result.e = pcre.study(result.h, options, addr msg)
     if not isNil(msg): raiseInvalidRegex($msg)
 
+proc rex*(s: string, flags = {reStudy, reExtended}): Regex =
+  ## Constructor for extended regular expressions.
+  ##
+  ## The extended means that comments starting with `#` and
+  ## whitespace are ignored.
+  result = re(s, flags)
+
 proc bufSubstr(b: cstring, sPos, ePos: int): string {.inline.} =
   ## Return a Nim string built from a slice of a cstring buffer.
   ## Don't assume cstring is '\0' terminated
25 ^
2565d3d10 ^
808863325 ^
2565d3d10 ^


808863325 ^
2565d3d10 ^
808863325 ^
2565d3d10 ^
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40