Update library.md (#555)

Fix string.match and string.find type definitions
This commit is contained in:
Arseny Kapoulkine 2022-06-22 09:27:05 -07:00 committed by GitHub
parent e0ac24d1ed
commit ca32d1bf9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -488,7 +488,7 @@ function string.char(args: ...number): string
Returns the string that contains a byte for every input number; all inputs must be integers in `[0..255]` range. Returns the string that contains a byte for every input number; all inputs must be integers in `[0..255]` range.
``` ```
function string.find(s: string, p: string, init: number?, plain: boolean?): (number?, number?) function string.find(s: string, p: string, init: number?, plain: boolean?): (number?, number?, ...string)
``` ```
Tries to find an instance of pattern `p` in the string `s`, starting from position `init` (defaults to 1). When `plain` is true, the search is using raw case-insensitive string equality, otherwise `p` should be a [string pattern](https://www.lua.org/manual/5.3/manual.html#6.4.1). If a match is found, returns the position of the match and the length of the match, followed by the pattern captures; otherwise returns `nil`. Tries to find an instance of pattern `p` in the string `s`, starting from position `init` (defaults to 1). When `plain` is true, the search is using raw case-insensitive string equality, otherwise `p` should be a [string pattern](https://www.lua.org/manual/5.3/manual.html#6.4.1). If a match is found, returns the position of the match and the length of the match, followed by the pattern captures; otherwise returns `nil`.
@ -536,7 +536,7 @@ function string.lower(s: string): string
Returns a string where each byte corresponds to the lower-case ASCII version of the input byte in the source string. Returns a string where each byte corresponds to the lower-case ASCII version of the input byte in the source string.
``` ```
function string.match(s: string, p: string, init: number?): (number?, number?) function string.match(s: string, p: string, init: number?): ...string?
``` ```
Tries to find an instance of pattern `p` in the string `s`, starting from position `init` (defaults to 1). `p` should be a [string pattern](https://www.lua.org/manual/5.3/manual.html#6.4.1). If a match is found, returns all pattern captures, or entire matching substring if no captures are present, otherwise returns `nil`. Tries to find an instance of pattern `p` in the string `s`, starting from position `init` (defaults to 1). `p` should be a [string pattern](https://www.lua.org/manual/5.3/manual.html#6.4.1). If a match is found, returns all pattern captures, or entire matching substring if no captures are present, otherwise returns `nil`.