@@ -153,25 +153,25 @@ impl UserData for RegexSet {
153
153
/// Compiles a regular expression.
154
154
///
155
155
/// Once compiled, it can be used repeatedly to search, split or replace substrings in a text.
156
- pub fn regex_new ( lua : & Lua , re : LuaString ) -> Result < StdResult < Regex , String > > {
156
+ pub fn new ( lua : & Lua , re : LuaString ) -> Result < StdResult < Regex , String > > {
157
157
let re = re. to_str ( ) ?;
158
158
Ok ( Ok ( lua_try ! ( Regex :: new( lua, & re) ) ) )
159
159
}
160
160
161
161
/// Escapes a string so that it can be used as a literal in a regular expression.
162
- pub fn regex_escape ( _: & Lua , text : LuaString ) -> Result < String > {
162
+ pub fn escape ( _: & Lua , text : LuaString ) -> Result < String > {
163
163
Ok ( regex:: escape ( & text. to_str ( ) ?) )
164
164
}
165
165
166
166
/// Returns true if there is a match for the regex anywhere in the given text.
167
- pub fn regex_is_match ( lua : & Lua , ( re, text) : ( LuaString , LuaString ) ) -> Result < StdResult < bool , String > > {
167
+ pub fn is_match ( lua : & Lua , ( re, text) : ( LuaString , LuaString ) ) -> Result < StdResult < bool , String > > {
168
168
let re = re. to_str ( ) ?;
169
169
let re = lua_try ! ( Regex :: new( lua, & re) ) ;
170
170
Ok ( Ok ( re. is_match ( & text. as_bytes ( ) ) ) )
171
171
}
172
172
173
173
/// Returns all matches of the regex in the given text or nil if there is no match.
174
- pub fn regex_match ( lua : & Lua , ( re, text) : ( LuaString , LuaString ) ) -> Result < StdResult < Value , String > > {
174
+ pub fn r#match ( lua : & Lua , ( re, text) : ( LuaString , LuaString ) ) -> Result < StdResult < Value , String > > {
175
175
let re = re. to_str ( ) ?;
176
176
let re = lua_try ! ( Regex :: new( lua, & re) ) ;
177
177
match re. captures ( & text. as_bytes ( ) ) {
@@ -189,10 +189,10 @@ pub fn regex_match(lua: &Lua, (re, text): (LuaString, LuaString)) -> Result<StdR
189
189
/// A loader for the `regex` module.
190
190
fn loader ( lua : & Lua ) -> Result < Table > {
191
191
let t = lua. create_table ( ) ?;
192
- t. set ( "new" , lua. create_function ( regex_new ) ?) ?;
193
- t. set ( "escape" , lua. create_function ( regex_escape ) ?) ?;
194
- t. set ( "is_match" , lua. create_function ( regex_is_match ) ?) ?;
195
- t. set ( "match" , lua. create_function ( regex_match ) ?) ?;
192
+ t. set ( "new" , lua. create_function ( new ) ?) ?;
193
+ t. set ( "escape" , lua. create_function ( escape ) ?) ?;
194
+ t. set ( "is_match" , lua. create_function ( is_match ) ?) ?;
195
+ t. set ( "match" , lua. create_function ( r#match ) ?) ?;
196
196
t. set ( "RegexSet" , lua. create_proxy :: < RegexSet > ( ) ?) ?;
197
197
Ok ( t)
198
198
}
0 commit comments