diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/js/jsre.nim | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/js/jsre.nim b/lib/js/jsre.nim index b4f273d0b..ff80056ea 100644 --- a/lib/js/jsre.nim +++ b/lib/js/jsre.nim @@ -1,5 +1,18 @@ ## Regular Expressions for the JavaScript target. ## * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions +## +## Examples +## ======== +## +## .. code-block::nim +## let jsregex: RegExp = newRegExp(r"\s+", r"i") +## jsregex.compile(r"\w+", r"i") +## doAssert jsregex.test(r"nim javascript") +## doAssert jsregex.exec(r"nim javascript") == @["nim".cstring] +## doAssert jsregex.toString() == r"/\w+/i" +## jsregex.compile(r"[0-9]", r"i") +## doAssert jsregex.test(r"0123456789abcd") + when not defined(js) and not defined(Nimdoc): {.error: "This module only works on the JavaScript platform".} @@ -34,13 +47,3 @@ func test*(self: RegExp; pattern: cstring): bool {.importjs: "#.test(#)".} func toString*(self: RegExp): cstring {.importjs: "#.toString()".} ## Returns a string representing the RegExp object. - - -runnableExamples: - let jsregex: RegExp = newRegExp(r"\s+", r"i") - jsregex.compile(r"\w+", r"i") - doAssert jsregex.test(r"nim javascript") - doAssert jsregex.exec(r"nim javascript") == @["nim".cstring] - doAssert jsregex.toString() == r"/\w+/i" - jsregex.compile(r"[0-9]", r"i") - doAssert jsregex.test(r"0123456789abcd") |