mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-08 05:53:22 +00:00
@@ -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")
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user