mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-03 03:32:32 +00:00
strscans: Fix examples
This commit is contained in:
@@ -76,7 +76,7 @@ to a variable (that was passed to the ``scanf`` macro) while ``$[]`` merely
|
||||
optional tokens.
|
||||
|
||||
|
||||
In this example, we define a helper proc ``skipSep`` that skips some separators
|
||||
In this example, we define a helper proc ``someSep`` that skips some separators
|
||||
which we then use in our scanf pattern to help us in the matching process:
|
||||
|
||||
.. code-block:: nim
|
||||
@@ -86,14 +86,14 @@ which we then use in our scanf pattern to help us in the matching process:
|
||||
result = 0
|
||||
while input[start+result] in seps: inc result
|
||||
|
||||
if scanf(input, "$w${someSep}$w", key, value):
|
||||
if scanf(input, "$w$[someSep]$w", key, value):
|
||||
...
|
||||
|
||||
It also possible to pass arguments to a user definable matcher:
|
||||
|
||||
.. code-block:: nim
|
||||
|
||||
proc ndigits(input: string; start: int; intVal: var int; n: int): int =
|
||||
proc ndigits(input: string; intVal: var int; start: int; n: int): int =
|
||||
# matches exactly ``n`` digits. Matchers need to return 0 if nothing
|
||||
# matched or otherwise the number of processed chars.
|
||||
var x = 0
|
||||
|
||||
Reference in New Issue
Block a user