parent
0c41ac792b
commit
c4e03b540e
2 changed files with 13 additions and 11 deletions
|
|
@ -1,5 +1,18 @@
|
||||||
## Regular Expressions for the JavaScript target.
|
## Regular Expressions for the JavaScript target.
|
||||||
## * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
|
## * 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):
|
when not defined(js) and not defined(Nimdoc):
|
||||||
{.error: "This module only works on the JavaScript platform".}
|
{.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()".}
|
func toString*(self: RegExp): cstring {.importjs: "#.toString()".}
|
||||||
## Returns a string representing the RegExp object.
|
## 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_freertos_consts.nim
|
||||||
lib/posix/posix_openbsd_amd64.nim
|
lib/posix/posix_openbsd_amd64.nim
|
||||||
lib/posix/posix_haiku.nim
|
lib/posix/posix_haiku.nim
|
||||||
lib/js/jsre.nim
|
|
||||||
""".splitWhitespace()
|
""".splitWhitespace()
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 1) or not declared(isRelativeTo):
|
when (NimMajor, NimMinor) < (1, 1) or not declared(isRelativeTo):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue