From 3f3dda5a77fa8faf6d97aa5a0ed3b0fc6e8c0918 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Wed, 23 Sep 2009 23:38:00 +0200 Subject: implemented multi methods --- lib/pure/regexprs.nim | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/pure/regexprs.nim') diff --git a/lib/pure/regexprs.nim b/lib/pure/regexprs.nim index 3a6ca72ae..54f9dc471 100755 --- a/lib/pure/regexprs.nim +++ b/lib/pure/regexprs.nim @@ -8,6 +8,9 @@ # ## Regular expression support for Nimrod. +## **Deprecated** since version 0.8.2. Use the module `re` instead. +{.deprecated.} + ## Currently this module is implemented by providing a wrapper around the ## `PRCE (Perl-Compatible Regular Expressions) `_ ## C library. This means that your application will depend on the PRCE @@ -131,13 +134,14 @@ template `=~` *(s, pattern: expr): expr = ## echo("comment: ", matches[1]) ## else: ## echo("syntax error") - ## - var matches: array[0..maxSubPatterns-1, string] + ## + when not definedInScope(matches): + var matches: array[0..maxSubPatterns-1, string] match(s, pattern, matches) const ## common regular expressions - reIdentifier* = r"\b[a-zA-Z_]+[a-zA-Z_0-9]*\b" ## describes an identifier + reIdentifier* = r"\b[a-zA-Z_][a-zA-Z_0-9]*\b" ## describes an identifier reNatural* = r"\b\d+\b" ## describes a natural number reInteger* = r"\b[-+]?\d+\b" ## describes an integer reHex* = r"\b0[xX][0-9a-fA-F]+\b" ## describes a hexadecimal number -- cgit 1.4.1-2-gfad0