mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-02 11:12:37 +00:00
Change readme formatting
This commit is contained in:
@@ -21,10 +21,10 @@ provides in its standard library is inadequate:
|
||||
|
||||
== Documentation
|
||||
|
||||
=== Procedures
|
||||
=== Operations
|
||||
|
||||
[[proc-match]]
|
||||
==== `match(string, Regex, start = 0, endpos = -1): RegexMatch`
|
||||
==== match(string, Regex, start = 0, endpos = -1): RegexMatch
|
||||
|
||||
Tries to match the pattern, starting at start. This means that
|
||||
`"foo".match(re"f") == true`, but `"foo".match(re"o") == false`.
|
||||
@@ -35,14 +35,14 @@ Tries to match the pattern, starting at start. This means that
|
||||
otherwise it's an exclusive upper bound.
|
||||
|
||||
[[proc-find]]
|
||||
==== `find(string, Regex, start = 0, endpos = -1): RegexMatch`
|
||||
==== find(string, Regex, start = 0, endpos = -1): RegexMatch
|
||||
|
||||
Finds the given pattern in the string. Bounds work the same as for
|
||||
link:#proc-match[`match(...)`], but instead of being anchored to the start of
|
||||
the string, it can match at any point between `start` and `endpos`.
|
||||
|
||||
[[iter-find]]
|
||||
==== `findIter(string, Regex, start = 0, endpos = -1): RegexMatch`
|
||||
==== findIter(string, Regex, start = 0, endpos = -1): RegexMatch
|
||||
|
||||
Works the same as link:#proc-find[`find(...)`], but finds every non-overlapping
|
||||
match. `"2222".find(re"22")` is `"22", "22"`, not `"22", "22", "22"`.
|
||||
@@ -55,7 +55,7 @@ Variants:
|
||||
- `findAllStr(...)` returns a `seq[string]`
|
||||
|
||||
[[proc-split]]
|
||||
==== `split(string, Regex): seq[string]`
|
||||
==== split(string, Regex): seq[string]
|
||||
|
||||
Splits the string with the given regex. This works according to the rules that
|
||||
Perl and Javascript use.
|
||||
@@ -66,7 +66,7 @@ Perl and Javascript use.
|
||||
`"12".split(re"(\d)") == @["", "1", "", "2", ""]`.
|
||||
|
||||
[[proc-replace]]
|
||||
==== `replace(string, Regex, sub): string`
|
||||
==== replace(string, Regex, sub): string
|
||||
|
||||
Replaces each match of Regex in the string with `sub`.
|
||||
|
||||
@@ -77,7 +77,7 @@ If `sub` is a string, then each match is replaced with that string, where the
|
||||
captures are accessable as `$1`, `$2`, and so on. A literal `$` can be added by
|
||||
doubling up like so: `$$`.
|
||||
|
||||
=== `RegexMatch`
|
||||
=== RegexMatch
|
||||
|
||||
Represents the result of an execution. On failure, it is `nil`. The available
|
||||
fields are as follows:
|
||||
@@ -104,7 +104,7 @@ is inclusive.
|
||||
as a key.
|
||||
`(captureBounds|capture).toSeq` :: returns all the captures by their number.
|
||||
|
||||
=== `Pattern`
|
||||
=== Pattern
|
||||
|
||||
Represents the pattern that things are matched against, constructed with
|
||||
`initRegex(string)` or `re(string)`. Examples: `re"foo"`, `re(r"foo # comment",
|
||||
|
||||
Reference in New Issue
Block a user