This commit is contained in:
Juan Carlos
2020-09-11 03:57:57 -03:00
committed by GitHub
parent 0c41ac792b
commit c4e03b540e
2 changed files with 13 additions and 11 deletions

View File

@@ -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")

View File

@@ -161,7 +161,6 @@ lib/posix/posix_other_consts.nim
lib/posix/posix_freertos_consts.nim
lib/posix/posix_openbsd_amd64.nim
lib/posix/posix_haiku.nim
lib/js/jsre.nim
""".splitWhitespace()
when (NimMajor, NimMinor) < (1, 1) or not declared(isRelativeTo):