mirror of
https://github.com/lune-org/lune.git
synced 2025-04-10 21:40:54 +01:00
Merge branch 'main' into datetime-properties
This commit is contained in:
commit
0ea3506614
4 changed files with 309 additions and 323 deletions
|
@ -8,6 +8,12 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## `0.8.9` - October 7th, 2024
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Updated to Luau version `0.640`
|
||||||
|
|
||||||
## `0.8.8` - August 22nd, 2024
|
## `0.8.8` - August 22nd, 2024
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
525
Cargo.lock
generated
525
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "lune"
|
name = "lune"
|
||||||
version = "0.8.8"
|
version = "0.8.9"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MPL-2.0"
|
license = "MPL-2.0"
|
||||||
repository = "https://github.com/lune-org/lune"
|
repository = "https://github.com/lune-org/lune"
|
||||||
|
|
|
@ -19,67 +19,82 @@ local RegexMatch = {
|
||||||
|
|
||||||
type RegexMatch = typeof(RegexMatch)
|
type RegexMatch = typeof(RegexMatch)
|
||||||
|
|
||||||
|
local RegexCaptures = {}
|
||||||
|
|
||||||
|
function RegexCaptures.get(self: RegexCaptures, index: number): RegexMatch?
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
|
function RegexCaptures.group(self: RegexCaptures, group: string): RegexMatch?
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
|
function RegexCaptures.format(self: RegexCaptures, format: string): string
|
||||||
|
return nil :: any
|
||||||
|
end
|
||||||
|
|
||||||
--[=[
|
--[=[
|
||||||
@class RegexCaptures
|
@class RegexCaptures
|
||||||
|
|
||||||
Captures from a regular expression.
|
Captures from a regular expression.
|
||||||
]=]
|
]=]
|
||||||
local RegexCaptures = {}
|
export type RegexCaptures = typeof(setmetatable(
|
||||||
|
{} :: {
|
||||||
|
--[=[
|
||||||
|
@within RegexCaptures
|
||||||
|
@tag Method
|
||||||
|
@method get
|
||||||
|
|
||||||
--[=[
|
Returns the match at the given index, if one exists.
|
||||||
@within RegexCaptures
|
|
||||||
@tag Method
|
|
||||||
|
|
||||||
Returns the match at the given index, if one exists.
|
@param index -- The index of the match to get
|
||||||
|
@return RegexMatch -- The match, if one exists
|
||||||
|
]=]
|
||||||
|
|
||||||
@param index -- The index of the match to get
|
get: (self: RegexCaptures, index: number) -> RegexMatch?,
|
||||||
@return RegexMatch -- The match, if one exists
|
|
||||||
]=]
|
|
||||||
function RegexCaptures.get(self: RegexCaptures, index: number): RegexMatch?
|
|
||||||
return nil :: any
|
|
||||||
end
|
|
||||||
|
|
||||||
--[=[
|
--[=[
|
||||||
@within RegexCaptures
|
@within RegexCaptures
|
||||||
@tag Method
|
@tag Method
|
||||||
|
@method group
|
||||||
|
|
||||||
Returns the match for the given named match group, if one exists.
|
Returns the match for the given named match group, if one exists.
|
||||||
|
|
||||||
@param group -- The name of the group to get
|
@param group -- The name of the group to get
|
||||||
@return RegexMatch -- The match, if one exists
|
@return RegexMatch -- The match, if one exists
|
||||||
]=]
|
]=]
|
||||||
function RegexCaptures.group(self: RegexCaptures, group: string): RegexMatch?
|
group: (self: RegexCaptures, group: string) -> RegexMatch?,
|
||||||
return nil :: any
|
|
||||||
end
|
|
||||||
|
|
||||||
--[=[
|
--[=[
|
||||||
@within RegexCaptures
|
@within RegexCaptures
|
||||||
@tag Method
|
@tag Method
|
||||||
|
@method format
|
||||||
|
|
||||||
Formats the captures using the given format string.
|
Formats the captures using the given format string.
|
||||||
|
|
||||||
### Example usage
|
### Example usage
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local regex = require("@lune/regex")
|
local regex = require("@lune/regex")
|
||||||
|
|
||||||
local re = regex.new("(?<day>[0-9]{2})-(?<month>[0-9]{2})-(?<year>[0-9]{4})")
|
local re = regex.new("(?<day>[0-9]{2})-(?<month>[0-9]{2})-(?<year>[0-9]{4})")
|
||||||
|
|
||||||
local caps = re:captures("On 14-03-2010, I became a Tenneessee lamb.");
|
local caps = re:captures("On 14-03-2010, I became a Tenneessee lamb.");
|
||||||
assert(caps ~= nil, "Example pattern should match example text")
|
assert(caps ~= nil, "Example pattern should match example text")
|
||||||
|
|
||||||
local formatted = caps:format("year=$year, month=$month, day=$day")
|
local formatted = caps:format("year=$year, month=$month, day=$day")
|
||||||
print(formatted) -- "year=2010, month=03, day=14"
|
print(formatted) -- "year=2010, month=03, day=14"
|
||||||
```
|
```
|
||||||
|
|
||||||
@param format -- The format string to use
|
@param format -- The format string to use
|
||||||
@return string -- The formatted string
|
@return string -- The formatted string
|
||||||
]=]
|
]=]
|
||||||
function RegexCaptures.format(self: RegexCaptures, format: string): string
|
format: (self: RegexCaptures, format: string) -> string,
|
||||||
return nil :: any
|
},
|
||||||
end
|
{} :: {
|
||||||
|
__len: (self: RegexCaptures) -> number,
|
||||||
export type RegexCaptures = typeof(RegexCaptures)
|
}
|
||||||
|
))
|
||||||
|
|
||||||
local Regex = {}
|
local Regex = {}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue