jsre.html 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <!-- This file is generated by Nim. -->
  4. <html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en" data-theme="auto">
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8. <title>std/jsre</title>
  9. <!-- Google fonts -->
  10. <link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
  11. <link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
  12. <!-- Favicon -->
  13. <link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
  14. <link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
  15. <!-- CSS -->
  16. <link rel="stylesheet" type="text/css" href="nimdoc.out.css?v=2.3.1">
  17. <!-- JS -->
  18. <script type="text/javascript" src="dochack.js?v=2.3.1"></script>
  19. </head>
  20. <body>
  21. <div class="document" id="documentId">
  22. <div class="container">
  23. <h1 class="title">std/jsre</h1>
  24. <div class="row">
  25. <div class="three columns">
  26. <div class="theme-select-wrapper">
  27. <label for="theme-select">Theme:&nbsp;</label>
  28. <select id="theme-select" onchange="setTheme(this.value)">
  29. <option value="auto">🌗 Match OS</option>
  30. <option value="dark">🌑 Dark</option>
  31. <option value="light">🌕 Light</option>
  32. </select>
  33. </div>
  34. <div id="global-links">
  35. <ul class="simple-boot">
  36. <li><a href="manual.html">Manual</a></li>
  37. <li><a href="lib.html">Standard library</a></li>
  38. <li> <a id="indexLink" href="theindex.html">Index</a></li>
  39. <li><a href="compiler/theindex.html">Compiler docs</a></li>
  40. <li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
  41. <li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
  42. </ul>
  43. </div>
  44. <div id="searchInputDiv">
  45. Search: <input type="search" id="searchInput"
  46. oninput="search()" />
  47. </div>
  48. <ul class="simple simple-toc" id="toc-list">
  49. <li>
  50. <details open>
  51. <summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
  52. <ul class="simple simple-toc-section">
  53. <li><a class="reference" href="#RegExp" title="RegExp = ref object of JsRoot
  54. flags*: cstring ## cstring that contains the flags of the RegExp object.
  55. dotAll*: bool ## Whether `.` matches newlines or not.
  56. global*: bool ## Whether to test against all possible matches in a string, or only against the first.
  57. ignoreCase*: bool ## Whether to ignore case while attempting a match in a string.
  58. multiline*: bool ## Whether to search in strings across multiple lines.
  59. source*: cstring ## The text of the pattern.
  60. sticky*: bool ## Whether the search is sticky.
  61. unicode*: bool ## Whether Unicode features are enabled.
  62. lastIndex*: cint ## Index at which to start the next match (read/write property).
  63. input*: cstring ## Read-only and modified on successful match.
  64. lastMatch*: cstring ## Ditto.
  65. lastParen*: cstring ## Ditto.
  66. leftContext*: cstring ## Ditto.
  67. rightContext*: cstring ## Ditto.
  68. hasIndices*: bool ## https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/hasIndices">RegExp</a></li>
  69. </ul>
  70. </details>
  71. </li>
  72. <li>
  73. <details open>
  74. <summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
  75. <ul class="simple simple-toc-section">
  76. <ul class="simple nested-toc-section">$
  77. <li><a class="reference" href="#%24%2CRegExp" title="`$`(self: RegExp): string">`$`(self: RegExp): string</a></li>
  78. </ul>
  79. <ul class="simple nested-toc-section">compile
  80. <li><a class="reference" href="#compile%2CRegExp%2Ccstring%2Ccstring" title="compile(self: RegExp; pattern: cstring; flags: cstring)">compile(self: RegExp; pattern: cstring; flags: cstring)</a></li>
  81. </ul>
  82. <ul class="simple nested-toc-section">contains
  83. <li><a class="reference" href="#contains%2Ccstring%2CRegExp" title="contains(pattern: cstring; self: RegExp): bool">contains(pattern: cstring; self: RegExp): bool</a></li>
  84. </ul>
  85. <ul class="simple nested-toc-section">endsWith
  86. <li><a class="reference" href="#endsWith%2Ccstring%2CRegExp" title="endsWith(pattern: cstring; self: RegExp): bool">endsWith(pattern: cstring; self: RegExp): bool</a></li>
  87. </ul>
  88. <ul class="simple nested-toc-section">exec
  89. <li><a class="reference" href="#exec%2CRegExp%2Ccstring" title="exec(self: RegExp; pattern: cstring): seq[cstring]">exec(self: RegExp; pattern: cstring): seq[cstring]</a></li>
  90. </ul>
  91. <ul class="simple nested-toc-section">match
  92. <li><a class="reference" href="#match%2Ccstring%2CRegExp" title="match(pattern: cstring; self: RegExp): seq[cstring]">match(pattern: cstring; self: RegExp): seq[cstring]</a></li>
  93. </ul>
  94. <ul class="simple nested-toc-section">newRegExp
  95. <li><a class="reference" href="#newRegExp%2Ccstring" title="newRegExp(pattern: cstring): RegExp">newRegExp(pattern: cstring): RegExp</a></li>
  96. <li><a class="reference" href="#newRegExp%2Ccstring%2Ccstring" title="newRegExp(pattern: cstring; flags: cstring): RegExp">newRegExp(pattern: cstring; flags: cstring): RegExp</a></li>
  97. </ul>
  98. <ul class="simple nested-toc-section">replace
  99. <li><a class="reference" href="#replace%2Ccstring%2CRegExp%2Cproc%28varargs%5Bcstring%5D%29" title="replace(pattern: cstring; self: RegExp;
  100. cb: proc (args: varargs[cstring]): cstring): cstring">replace(pattern: cstring; self: RegExp;
  101. cb: proc (args: varargs[cstring]): cstring): cstring</a></li>
  102. <li><a class="reference" href="#replace%2Ccstring%2CRegExp%2Ccstring" title="replace(pattern: cstring; self: RegExp; replacement: cstring): cstring">replace(pattern: cstring; self: RegExp; replacement: cstring): cstring</a></li>
  103. </ul>
  104. <ul class="simple nested-toc-section">split
  105. <li><a class="reference" href="#split%2Ccstring%2CRegExp" title="split(pattern: cstring; self: RegExp): seq[cstring]">split(pattern: cstring; self: RegExp): seq[cstring]</a></li>
  106. </ul>
  107. <ul class="simple nested-toc-section">startsWith
  108. <li><a class="reference" href="#startsWith%2Ccstring%2CRegExp" title="startsWith(pattern: cstring; self: RegExp): bool">startsWith(pattern: cstring; self: RegExp): bool</a></li>
  109. </ul>
  110. <ul class="simple nested-toc-section">toCstring
  111. <li><a class="reference" href="#toCstring%2CRegExp" title="toCstring(self: RegExp): cstring">toCstring(self: RegExp): cstring</a></li>
  112. </ul>
  113. </ul>
  114. </details>
  115. </li>
  116. </ul>
  117. </div>
  118. <div class="nine columns" id="content">
  119. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/js/jsre.nim#L1" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  120. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/js/jsre.nim#L1" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  121. <div id="tocRoot"></div>
  122. <p class="module-desc">Regular Expressions for the JavaScript target.<ul class="simple"><li><a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions</a></li>
  123. </ul>
  124. <p><strong class="examples_text">Example:</strong></p>
  125. <pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">jsre</span>
  126. <span class="Keyword">let</span> <span class="Identifier">jsregex</span><span class="Punctuation">:</span> <span class="Identifier">RegExp</span> <span class="Operator">=</span> <span class="Identifier">newRegExp</span><span class="Punctuation">(</span><span class="RawData">r&quot;\s+&quot;</span><span class="Punctuation">,</span> <span class="RawData">r&quot;i&quot;</span><span class="Punctuation">)</span>
  127. <span class="Identifier">jsregex</span><span class="Operator">.</span><span class="Identifier">compile</span><span class="Punctuation">(</span><span class="RawData">r&quot;\w+&quot;</span><span class="Punctuation">,</span> <span class="RawData">r&quot;i&quot;</span><span class="Punctuation">)</span>
  128. <span class="Identifier">assert</span> <span class="StringLit">&quot;nim javascript&quot;</span><span class="Operator">.</span><span class="Identifier">contains</span> <span class="Identifier">jsregex</span>
  129. <span class="Identifier">assert</span> <span class="Identifier">jsregex</span><span class="Operator">.</span><span class="Identifier">exec</span><span class="Punctuation">(</span><span class="RawData">r&quot;nim javascript&quot;</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="StringLit">&quot;nim&quot;</span><span class="Operator">.</span><span class="Identifier">cstring</span><span class="Punctuation">]</span>
  130. <span class="Identifier">assert</span> <span class="Identifier">jsregex</span><span class="Operator">.</span><span class="Identifier">toCstring</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="RawData">r&quot;/\w+/i&quot;</span>
  131. <span class="Identifier">jsregex</span><span class="Operator">.</span><span class="Identifier">compile</span><span class="Punctuation">(</span><span class="RawData">r&quot;[0-9]&quot;</span><span class="Punctuation">,</span> <span class="RawData">r&quot;i&quot;</span><span class="Punctuation">)</span>
  132. <span class="Identifier">assert</span> <span class="StringLit">&quot;0123456789abcd&quot;</span><span class="Operator">.</span><span class="Identifier">contains</span> <span class="Identifier">jsregex</span>
  133. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">jsregex</span> <span class="Operator">==</span> <span class="StringLit">&quot;/[0-9]/i&quot;</span>
  134. <span class="Identifier">jsregex</span><span class="Operator">.</span><span class="Identifier">compile</span><span class="Punctuation">(</span><span class="RawData">r&quot;abc&quot;</span><span class="Punctuation">,</span> <span class="RawData">r&quot;i&quot;</span><span class="Punctuation">)</span>
  135. <span class="Identifier">assert</span> <span class="StringLit">&quot;abcd&quot;</span><span class="Operator">.</span><span class="Identifier">startsWith</span> <span class="Identifier">jsregex</span>
  136. <span class="Identifier">assert</span> <span class="StringLit">&quot;dabc&quot;</span><span class="Operator">.</span><span class="Identifier">endsWith</span> <span class="Identifier">jsregex</span>
  137. <span class="Identifier">jsregex</span><span class="Operator">.</span><span class="Identifier">compile</span><span class="Punctuation">(</span><span class="RawData">r&quot;\d&quot;</span><span class="Punctuation">,</span> <span class="RawData">r&quot;i&quot;</span><span class="Punctuation">)</span>
  138. <span class="Identifier">assert</span> <span class="StringLit">&quot;do1ne&quot;</span><span class="Operator">.</span><span class="Identifier">split</span><span class="Punctuation">(</span><span class="Identifier">jsregex</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="StringLit">&quot;do&quot;</span><span class="Operator">.</span><span class="Identifier">cstring</span><span class="Punctuation">,</span> <span class="StringLit">&quot;ne&quot;</span><span class="Operator">.</span><span class="Identifier">cstring</span><span class="Punctuation">]</span>
  139. <span class="Identifier">jsregex</span><span class="Operator">.</span><span class="Identifier">compile</span><span class="Punctuation">(</span><span class="RawData">r&quot;[lw]&quot;</span><span class="Punctuation">,</span> <span class="RawData">r&quot;i&quot;</span><span class="Punctuation">)</span>
  140. <span class="Identifier">assert</span> <span class="StringLit">&quot;hello world&quot;</span><span class="Operator">.</span><span class="Identifier">replace</span><span class="Punctuation">(</span><span class="Identifier">jsregex</span><span class="Punctuation">,</span><span class="StringLit">&quot;X&quot;</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;heXlo world&quot;</span>
  141. <span class="Identifier">jsregex</span><span class="Operator">.</span><span class="Identifier">compile</span><span class="Punctuation">(</span><span class="RawData">r&quot;([a-z])\1*&quot;</span><span class="Punctuation">,</span> <span class="RawData">r&quot;g&quot;</span><span class="Punctuation">)</span>
  142. <span class="Identifier">assert</span> <span class="StringLit">&quot;abbcccdddd&quot;</span><span class="Operator">.</span><span class="Identifier">replace</span><span class="Punctuation">(</span><span class="Identifier">jsregex</span><span class="Punctuation">,</span> <span class="Keyword">proc</span> <span class="Punctuation">(</span><span class="Identifier">m</span><span class="Punctuation">:</span> <span class="Identifier">varargs</span><span class="Punctuation">[</span><span class="Identifier">cstring</span><span class="Punctuation">]</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">cstring</span> <span class="Operator">=</span> <span class="Punctuation">(</span><span class="Operator">$</span><span class="Identifier">m</span><span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">]</span> <span class="Operator">&amp;</span> <span class="Operator">$</span><span class="Punctuation">(</span><span class="Identifier">m</span><span class="Operator">.</span><span class="Identifier">len</span><span class="Punctuation">)</span><span class="Punctuation">)</span><span class="Operator">.</span><span class="Identifier">cstring</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;a1b2c3d4&quot;</span>
  143. <span class="Keyword">let</span> <span class="Identifier">digitsRegex</span><span class="Punctuation">:</span> <span class="Identifier">RegExp</span> <span class="Operator">=</span> <span class="Identifier">newRegExp</span><span class="Punctuation">(</span><span class="RawData">r&quot;\d&quot;</span><span class="Punctuation">)</span>
  144. <span class="Identifier">assert</span> <span class="StringLit">&quot;foo&quot;</span><span class="Operator">.</span><span class="Identifier">match</span><span class="Punctuation">(</span><span class="Identifier">digitsRegex</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="Punctuation">]</span></pre></p>
  145. <div class="section" id="7">
  146. <h1><a class="toc-backref" href="#7">Types</a></h1>
  147. <dl class="item">
  148. <div id="RegExp">
  149. <dt><pre><a href="jsre.html#RegExp"><span class="Identifier">RegExp</span></a> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="system.html#JsRoot"><span class="Identifier">JsRoot</span></a>
  150. <span class="Identifier">flags</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a> <span class="Comment">## cstring that contains the flags of the RegExp object.</span>
  151. <span class="Identifier">dotAll</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> <span class="Comment">## Whether `.` matches newlines or not.</span>
  152. <span class="Identifier">global</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> <span class="Comment">## Whether to test against all possible matches in a string, or only against the first.</span>
  153. <span class="Identifier">ignoreCase</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> <span class="Comment">## Whether to ignore case while attempting a match in a string.</span>
  154. <span class="Identifier">multiline</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> <span class="Comment">## Whether to search in strings across multiple lines.</span>
  155. <span class="Identifier">source</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a> <span class="Comment">## The text of the pattern.</span>
  156. <span class="Identifier">sticky</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> <span class="Comment">## Whether the search is sticky.</span>
  157. <span class="Identifier">unicode</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> <span class="Comment">## Whether Unicode features are enabled.</span>
  158. <span class="Identifier">lastIndex</span><span class="Operator">*</span><span class="Other">:</span> <a href="ctypes.html#cint"><span class="Identifier">cint</span></a> <span class="Comment">## Index at which to start the next match (read/write property).</span>
  159. <span class="Identifier">input</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a> <span class="Comment">## Read-only and modified on successful match.</span>
  160. <span class="Identifier">lastMatch</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a> <span class="Comment">## Ditto.</span>
  161. <span class="Identifier">lastParen</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a> <span class="Comment">## Ditto.</span>
  162. <span class="Identifier">leftContext</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a> <span class="Comment">## Ditto.</span>
  163. <span class="Identifier">rightContext</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a> <span class="Comment">## Ditto.</span>
  164. <span class="Identifier">hasIndices</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> <span class="Comment">## https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/hasIndices</span></pre></dt>
  165. <dd>
  166. Regular Expressions for JavaScript target. See <a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp</a>
  167. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/js/jsre.nim#L6" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  168. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/js/jsre.nim#L6" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  169. </dd>
  170. </div>
  171. </dl>
  172. </div>
  173. <div class="section" id="12">
  174. <h1><a class="toc-backref" href="#12">Procs</a></h1>
  175. <dl class="item">
  176. <div id="$-procs-all">
  177. <div id="$,RegExp">
  178. <dt><pre><span class="Keyword">func</span> <a href="#%24%2CRegExp"><span class="Identifier">`$`</span></a><span class="Other">(</span><span class="Identifier">self</span><span class="Other">:</span> <a href="jsre.html#RegExp"><span class="Identifier">RegExp</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  179. <dd>
  180. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/js/jsre.nim#L52" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  181. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/js/jsre.nim#L52" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  182. </dd>
  183. </div>
  184. </div>
  185. <div id="compile-procs-all">
  186. <div id="compile,RegExp,cstring,cstring">
  187. <dt><pre><span class="Keyword">func</span> <a href="#compile%2CRegExp%2Ccstring%2Ccstring"><span class="Identifier">compile</span></a><span class="Other">(</span><span class="Identifier">self</span><span class="Other">:</span> <a href="jsre.html#RegExp"><span class="Identifier">RegExp</span></a><span class="Other">;</span> <span class="Identifier">pattern</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a><span class="Other">;</span> <span class="Identifier">flags</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a><span class="Other">)</span> {.
  188. <span class="Identifier">importjs</span><span class="Other">:</span> <span class="StringLit">&quot;#.compile(@)&quot;</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  189. <dd>
  190. Recompiles a regular expression during execution of a script.
  191. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/js/jsre.nim#L31" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  192. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/js/jsre.nim#L31" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  193. </dd>
  194. </div>
  195. </div>
  196. <div id="contains-procs-all">
  197. <div id="contains,cstring,RegExp">
  198. <dt><pre><span class="Keyword">func</span> <a href="#contains%2Ccstring%2CRegExp"><span class="Identifier">contains</span></a><span class="Other">(</span><span class="Identifier">pattern</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a><span class="Other">;</span> <span class="Identifier">self</span><span class="Other">:</span> <a href="jsre.html#RegExp"><span class="Identifier">RegExp</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  199. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  200. <dd>
  201. Tests for a substring match in its string parameter.
  202. <p><strong class="examples_text">Example:</strong></p>
  203. <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">jsregex</span><span class="Punctuation">:</span> <span class="Identifier">RegExp</span> <span class="Operator">=</span> <span class="Identifier">newRegExp</span><span class="Punctuation">(</span><span class="RawData">r&quot;bc$&quot;</span><span class="Punctuation">,</span> <span class="RawData">r&quot;i&quot;</span><span class="Punctuation">)</span>
  204. <span class="Identifier">assert</span> <span class="Identifier">jsregex</span> <span class="Keyword">in</span> <span class="RawData">r&quot;abc&quot;</span>
  205. <span class="Identifier">assert</span> <span class="Identifier">jsregex</span> <span class="Keyword">notin</span> <span class="RawData">r&quot;abcd&quot;</span>
  206. <span class="Identifier">assert</span> <span class="StringLit">&quot;xabc&quot;</span><span class="Operator">.</span><span class="Identifier">contains</span> <span class="Identifier">jsregex</span></pre>
  207. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/js/jsre.nim#L54" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  208. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/js/jsre.nim#L54" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  209. </dd>
  210. </div>
  211. </div>
  212. <div id="endsWith-procs-all">
  213. <div id="endsWith,cstring,RegExp">
  214. <dt><pre><span class="Keyword">func</span> <a href="#endsWith%2Ccstring%2CRegExp"><span class="Identifier">endsWith</span></a><span class="Other">(</span><span class="Identifier">pattern</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a><span class="Other">;</span> <span class="Identifier">self</span><span class="Other">:</span> <a href="jsre.html#RegExp"><span class="Identifier">RegExp</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  215. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  216. <dd>
  217. Tests if string ends with given RegExp
  218. <p><strong class="examples_text">Example:</strong></p>
  219. <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">jsregex</span><span class="Punctuation">:</span> <span class="Identifier">RegExp</span> <span class="Operator">=</span> <span class="Identifier">newRegExp</span><span class="Punctuation">(</span><span class="RawData">r&quot;bcd&quot;</span><span class="Punctuation">,</span> <span class="RawData">r&quot;i&quot;</span><span class="Punctuation">)</span>
  220. <span class="Identifier">assert</span> <span class="StringLit">&quot;abcd&quot;</span><span class="Operator">.</span><span class="Identifier">endsWith</span> <span class="Identifier">jsregex</span></pre>
  221. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/js/jsre.nim#L70" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  222. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/js/jsre.nim#L70" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  223. </dd>
  224. </div>
  225. </div>
  226. <div id="exec-procs-all">
  227. <div id="exec,RegExp,cstring">
  228. <dt><pre><span class="Keyword">func</span> <a href="#exec%2CRegExp%2Ccstring"><span class="Identifier">exec</span></a><span class="Other">(</span><span class="Identifier">self</span><span class="Other">:</span> <a href="jsre.html#RegExp"><span class="Identifier">RegExp</span></a><span class="Other">;</span> <span class="Identifier">pattern</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#seq"><span class="Identifier">seq</span></a><span class="Other">[</span><a href="system.html#cstring"><span class="Identifier">cstring</span></a><span class="Other">]</span> {.
  229. <span class="Identifier">importjs</span><span class="Other">:</span> <span class="StringLit">&quot;(#.exec(#) || [])&quot;</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  230. <dd>
  231. Executes a search for a match in its string parameter.
  232. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/js/jsre.nim#L46" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  233. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/js/jsre.nim#L46" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  234. </dd>
  235. </div>
  236. </div>
  237. <div id="match-procs-all">
  238. <div id="match,cstring,RegExp">
  239. <dt><pre><span class="Keyword">func</span> <a href="#match%2Ccstring%2CRegExp"><span class="Identifier">match</span></a><span class="Other">(</span><span class="Identifier">pattern</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a><span class="Other">;</span> <span class="Identifier">self</span><span class="Other">:</span> <a href="jsre.html#RegExp"><span class="Identifier">RegExp</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#seq"><span class="Identifier">seq</span></a><span class="Other">[</span><a href="system.html#cstring"><span class="Identifier">cstring</span></a><span class="Other">]</span> {.
  240. <span class="Identifier">importjs</span><span class="Other">:</span> <span class="StringLit">&quot;(#.match(#) || [])&quot;</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  241. <dd>
  242. Returns an array of matches of a RegExp against given string
  243. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/js/jsre.nim#L43" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  244. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/js/jsre.nim#L43" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  245. </dd>
  246. </div>
  247. </div>
  248. <div id="newRegExp-procs-all">
  249. <div id="newRegExp,cstring">
  250. <dt><pre><span class="Keyword">func</span> <a href="#newRegExp%2Ccstring"><span class="Identifier">newRegExp</span></a><span class="Other">(</span><span class="Identifier">pattern</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a><span class="Other">)</span><span class="Other">:</span> <a href="jsre.html#RegExp"><span class="Identifier">RegExp</span></a> {.<span class="Identifier">importjs</span><span class="Other">:</span> <span class="StringLit">&quot;new RegExp(@)&quot;</span><span class="Other">,</span>
  251. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  252. <dd>
  253. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/js/jsre.nim#L29" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  254. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/js/jsre.nim#L29" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  255. </dd>
  256. </div>
  257. <div id="newRegExp,cstring,cstring">
  258. <dt><pre><span class="Keyword">func</span> <a href="#newRegExp%2Ccstring%2Ccstring"><span class="Identifier">newRegExp</span></a><span class="Other">(</span><span class="Identifier">pattern</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a><span class="Other">;</span> <span class="Identifier">flags</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a><span class="Other">)</span><span class="Other">:</span> <a href="jsre.html#RegExp"><span class="Identifier">RegExp</span></a> {.
  259. <span class="Identifier">importjs</span><span class="Other">:</span> <span class="StringLit">&quot;new RegExp(@)&quot;</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  260. <dd>
  261. Creates a new RegExp object.
  262. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/js/jsre.nim#L26" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  263. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/js/jsre.nim#L26" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  264. </dd>
  265. </div>
  266. </div>
  267. <div id="replace-procs-all">
  268. <div id="replace,cstring,RegExp,proc(varargs[cstring])">
  269. <dt><pre><span class="Keyword">func</span> <a href="#replace%2Ccstring%2CRegExp%2Cproc%28varargs%5Bcstring%5D%29"><span class="Identifier">replace</span></a><span class="Other">(</span><span class="Identifier">pattern</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a><span class="Other">;</span> <span class="Identifier">self</span><span class="Other">:</span> <a href="jsre.html#RegExp"><span class="Identifier">RegExp</span></a><span class="Other">;</span>
  270. <span class="Identifier">cb</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">args</span><span class="Other">:</span> <a href="system.html#varargs"><span class="Identifier">varargs</span></a><span class="Other">[</span><a href="system.html#cstring"><span class="Identifier">cstring</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a> {.<span class="Identifier">importcpp</span><span class="Other">,</span>
  271. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  272. <dd>
  273. Returns a new string with some or all matches of a pattern replaced by given callback function
  274. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/js/jsre.nim#L37" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  275. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/js/jsre.nim#L37" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  276. </dd>
  277. </div>
  278. <div id="replace,cstring,RegExp,cstring">
  279. <dt><pre><span class="Keyword">func</span> <a href="#replace%2Ccstring%2CRegExp%2Ccstring"><span class="Identifier">replace</span></a><span class="Other">(</span><span class="Identifier">pattern</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a><span class="Other">;</span> <span class="Identifier">self</span><span class="Other">:</span> <a href="jsre.html#RegExp"><span class="Identifier">RegExp</span></a><span class="Other">;</span> <span class="Identifier">replacement</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a> {.
  280. <span class="Identifier">importjs</span><span class="Other">:</span> <span class="StringLit">&quot;#.replace(#, #)&quot;</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  281. <dd>
  282. Returns a new string with some or all matches of a pattern replaced by given replacement
  283. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/js/jsre.nim#L34" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  284. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/js/jsre.nim#L34" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  285. </dd>
  286. </div>
  287. </div>
  288. <div id="split-procs-all">
  289. <div id="split,cstring,RegExp">
  290. <dt><pre><span class="Keyword">func</span> <a href="#split%2Ccstring%2CRegExp"><span class="Identifier">split</span></a><span class="Other">(</span><span class="Identifier">pattern</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a><span class="Other">;</span> <span class="Identifier">self</span><span class="Other">:</span> <a href="jsre.html#RegExp"><span class="Identifier">RegExp</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#seq"><span class="Identifier">seq</span></a><span class="Other">[</span><a href="system.html#cstring"><span class="Identifier">cstring</span></a><span class="Other">]</span> {.
  291. <span class="Identifier">importjs</span><span class="Other">:</span> <span class="StringLit">&quot;(#.split(#) || [])&quot;</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  292. <dd>
  293. Divides a string into an ordered list of substrings and returns the array
  294. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/js/jsre.nim#L40" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  295. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/js/jsre.nim#L40" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  296. </dd>
  297. </div>
  298. </div>
  299. <div id="startsWith-procs-all">
  300. <div id="startsWith,cstring,RegExp">
  301. <dt><pre><span class="Keyword">func</span> <a href="#startsWith%2Ccstring%2CRegExp"><span class="Identifier">startsWith</span></a><span class="Other">(</span><span class="Identifier">pattern</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a><span class="Other">;</span> <span class="Identifier">self</span><span class="Other">:</span> <a href="jsre.html#RegExp"><span class="Identifier">RegExp</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  302. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  303. <dd>
  304. Tests if string starts with given RegExp
  305. <p><strong class="examples_text">Example:</strong></p>
  306. <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">jsregex</span><span class="Punctuation">:</span> <span class="Identifier">RegExp</span> <span class="Operator">=</span> <span class="Identifier">newRegExp</span><span class="Punctuation">(</span><span class="RawData">r&quot;abc&quot;</span><span class="Punctuation">,</span> <span class="RawData">r&quot;i&quot;</span><span class="Punctuation">)</span>
  307. <span class="Identifier">assert</span> <span class="StringLit">&quot;abcd&quot;</span><span class="Operator">.</span><span class="Identifier">startsWith</span> <span class="Identifier">jsregex</span></pre>
  308. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/js/jsre.nim#L63" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  309. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/js/jsre.nim#L63" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  310. </dd>
  311. </div>
  312. </div>
  313. <div id="toCstring-procs-all">
  314. <div id="toCstring,RegExp">
  315. <dt><pre><span class="Keyword">func</span> <a href="#toCstring%2CRegExp"><span class="Identifier">toCstring</span></a><span class="Other">(</span><span class="Identifier">self</span><span class="Other">:</span> <a href="jsre.html#RegExp"><span class="Identifier">RegExp</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a> {.<span class="Identifier">importjs</span><span class="Other">:</span> <span class="StringLit">&quot;#.toString()&quot;</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  316. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  317. <dd>
  318. Returns a string representing the RegExp object.
  319. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/js/jsre.nim#L49" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  320. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/js/jsre.nim#L49" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  321. </dd>
  322. </div>
  323. </div>
  324. </dl>
  325. </div>
  326. </div>
  327. </div>
  328. <div class="twelve-columns footer">
  329. <span class="nim-sprite"></span>
  330. <br>
  331. <small style="color: var(--hint);">Made with Nim. Generated: 2025-03-15 14:13:03 UTC</small>
  332. </div>
  333. </div>
  334. </div>
  335. <script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
  336. </body>
  337. </html>