Revert accidental reverting of tf-regex merge.
This commit is contained in:
parent
c9696ca230
commit
86ddf1fea0
@ -104,7 +104,7 @@ enum RegexError
|
|||||||
* @param errcode Regex type error code encountered, if applicable.
|
* @param errcode Regex type error code encountered, if applicable.
|
||||||
* @return Valid regex handle on success, INVALID_HANDLE on failure.
|
* @return Valid regex handle on success, INVALID_HANDLE on failure.
|
||||||
*/
|
*/
|
||||||
native Handle:CompileRegex(const String:pattern[], flags = 0, String:error[]="", maxLen = 0, &RegexError:errcode = REGEX_ERROR_NONE);
|
native Regex CompileRegex(const char[] pattern, int flags = 0, char[] error="", int maxLen = 0, RegexError &errcode = REGEX_ERROR_NONE);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matches a string against a pre-compiled regular expression pattern.
|
* Matches a string against a pre-compiled regular expression pattern.
|
||||||
@ -117,7 +117,7 @@ native Handle:CompileRegex(const String:pattern[], flags = 0, String:error[]="",
|
|||||||
* @note Use the regex handle passed to this function to extract
|
* @note Use the regex handle passed to this function to extract
|
||||||
* matches with GetRegexSubString().
|
* matches with GetRegexSubString().
|
||||||
*/
|
*/
|
||||||
native MatchRegex(Handle:regex, const String:str[], &RegexError:ret = REGEX_ERROR_NONE);
|
native int MatchRegex(Handle regex, const char[] str, RegexError &ret = REGEX_ERROR_NONE);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a matched substring from a regex handle.
|
* Returns a matched substring from a regex handle.
|
||||||
@ -130,7 +130,14 @@ native MatchRegex(Handle:regex, const String:str[], &RegexError:ret = REGEX_ERRO
|
|||||||
* @param maxlen The maximum string length of the buffer.
|
* @param maxlen The maximum string length of the buffer.
|
||||||
* @return True if a substring was found, False on fail/error
|
* @return True if a substring was found, False on fail/error
|
||||||
*/
|
*/
|
||||||
native bool:GetRegexSubString(Handle:regex, str_id, String:buffer[], maxlen);
|
native bool GetRegexSubString(Handle regex, int str_id, char[] buffer, int maxlen);
|
||||||
|
|
||||||
|
methodmap Regex < Handle
|
||||||
|
{
|
||||||
|
public Regex() = CompileRegex;
|
||||||
|
public Match() = MatchRegex;
|
||||||
|
public GetSubString() = GetRegexSubString;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matches a string against a regular expression pattern.
|
* Matches a string against a regular expression pattern.
|
||||||
@ -146,18 +153,14 @@ native bool:GetRegexSubString(Handle:regex, str_id, String:buffer[], maxlen);
|
|||||||
* @param maxLen Maximum length of the error buffer.
|
* @param maxLen Maximum length of the error buffer.
|
||||||
* @return Number of substrings found or -1 on failure.
|
* @return Number of substrings found or -1 on failure.
|
||||||
*/
|
*/
|
||||||
stock SimpleRegexMatch(const String:str[], const String:pattern[], flags = 0, String:error[]="", maxLen = 0)
|
stock int SimpleRegexMatch(const char[] str, const char[] pattern, int flags = 0, char[] error="", int maxLen = 0)
|
||||||
{
|
{
|
||||||
new Handle:regex = CompileRegex(pattern, flags, error, maxLen);
|
Regex regex = Regex(pattern, flags, error, maxLen);
|
||||||
|
if (!regex)
|
||||||
if (regex == INVALID_HANDLE)
|
|
||||||
{
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
new substrings = MatchRegex(regex, str);
|
int substrings = regex.Match(str);
|
||||||
|
delete regex;
|
||||||
CloseHandle(regex);
|
|
||||||
|
|
||||||
return substrings;
|
return substrings;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user