C# Класс GarrysModLuaShared.@string

The string type is a sequence of characters. The string library is a standard Lua library which provides functions for the manipulation of strings. In Garry's Mod there are several extra useful functions added to this library.
Показать файл Открыть проект

Открытые методы

Метод Описание
@byte ( LuaState luaState, string inputString, uint startPos = 1U, uint endPos = 1U ) : byte[]

Returns the given string's characters in their numeric ASCII representation.

@char ( LuaState luaState ) : string

Takes the given numerical bytes and converts them to a string.

Comma ( LuaState luaState, double inputNumber ) : string

Inserts commas for every third digit.

EndsWith ( LuaState luaState, string inputString, string endString ) : bool

Returns whether or not the second passed string matches the end of the first.

FormattedTime ( LuaState luaState, double @float, string format ) : string

Returns the time as a formatted string or as a table if no format is given.

GetExtensionFromFilename ( LuaState luaState, string fileName ) : string

Returns extension of the file.

GetFileFromFilename ( LuaState luaState, string fileName ) : string

Returns file name and extension.

GetPathFromFilename ( LuaState luaState, string fileName ) : string

Returns the path only from a file's path.

JavascriptSafe ( LuaState luaState, string inputString ) : string

Escapes special characters for JavaScript in a string, making the string safe for inclusion in to JavaScript strings.

Left ( LuaState luaState, string inputString, uint num ) : string

Returns everything left of supplied place of inputString.

NiceSize ( LuaState luaState, uint bytes ) : string

Converts supplied number into bytes.

NiceTime ( LuaState luaState, uint seconds ) : string

Converts supplied number into string.

PatternSafe ( LuaState luaState, string inputString ) : string

Escapes all special characters within a string, making the string safe for inclusion in a Lua pattern.

Replace ( LuaState luaState, string input, string find, string replace ) : string

Replaces all occurrences of the supplied second string.

Right ( LuaState luaState, string inputString, uint num ) : string

Returns the last n-th characters of the string.

SetChar ( LuaState luaState, string inputString, uint index, char replacement ) : string

Sets the character at the specific index of the string.

StartWith ( LuaState luaState, string inputString, string startString ) : bool

Returns whether or not the first string starts with the second.

StripExtension ( LuaState luaState, string fileName ) : string

Removes the extension of a path.

ToMinutesSeconds ( LuaState luaState, uint time ) : string

Returns the given time in "MM:SS" format.

ToMinutesSecondsMilliseconds ( LuaState luaState, double time ) : string

Returns the given time in "MM:SS:MS" format.

Trim ( LuaState luaState, string inputString, string match = " " ) : string

Removes leading and trailing matches of a string.

TrimLeft ( LuaState luaState, string inputString, string match = " " ) : string

Removes leading spaces/characters from a string.

TrimRight ( LuaState luaState, string inputString, string match = " " ) : string

Removes trailing spaces/passed character from a string.

find ( LuaState luaState, string hayStack, string needle, int startPos = 1, bool noPatterns = false ) : int>.Tuple

Attempts to find the specified substring in a string, uses patterns by default.

find ( LuaState luaState, int &start, int &end, string hayStack, string needle, int startPos = 1, bool noPatterns = false ) : void

Attempts to find the specified substring in a string, uses patterns by default.

format ( LuaState luaState, string inputString ) : string

Formats the specified values into the string given.

gsub ( LuaState luaState, string input, string pattern, string replacement, uint maxReplaces = default(uint) ) : uint>.Tuple

This functions main purpose is to replace certain character sequences in a string using patterns.

gsub ( LuaState luaState, string &replaceResult, uint &replaceCount, string input, string pattern, string replacement, uint maxReplaces = default(uint) ) : void

This functions main purpose is to replace certain character sequences in a string using patterns.

len ( LuaState luaState, string inputString ) : uint

Counts the number of characters in the string (length).

lower ( LuaState luaState, string inputString ) : string

Changes any upper-case letters in a inputString to lower-case letters.

match ( LuaState luaState, string inputString, string pattern, int startPosition ) : string

Finds a http://wiki.garrysmod.com/page/Patterns">pattern in a

rep ( LuaState luaState, string inputString, uint repetitions ) : string

Repeats a string by the given value.

reverse ( LuaState luaState, string inputString ) : string

Reverses a string.

sub ( LuaState luaState, string inputString, uint startPos, uint endPos = default(uint) ) : string

Returns a sub-string, starting from the character at position startPos of the string (inclusive), and optionally ending at the character at position endPos of the string (also inclusive). If endPos is not given, the rest of the string is returned.

upper ( LuaState luaState, string inputString ) : string

Changes any lower-case letters in a string to upper-case letters.

Описание методов

@byte() публичный статический Метод

Returns the given string's characters in their numeric ASCII representation.
public static @byte ( LuaState luaState, string inputString, uint startPos = 1U, uint endPos = 1U ) : byte[]
luaState LuaState Pointer to lua_State struct.
inputString string The string to get the chars from.
startPos uint The first character of the string to get the byte of.
endPos uint The last character of the string to get the byte of.
Результат byte[]

@char() публичный статический Метод

Takes the given numerical bytes and converts them to a string.
public static @char ( LuaState luaState ) : string
luaState LuaState Pointer to lua_State struct.
Результат string

Comma() публичный статический Метод

Inserts commas for every third digit.
public static Comma ( LuaState luaState, double inputNumber ) : string
luaState LuaState Pointer to lua_State struct.
inputNumber double The input number to commafy.
Результат string

EndsWith() публичный статический Метод

Returns whether or not the second passed string matches the end of the first.
public static EndsWith ( LuaState luaState, string inputString, string endString ) : bool
luaState LuaState Pointer to lua_State struct.
inputString string The string whose end is to be checked.
endString string The string to be matched with the end of the first.
Результат bool

FormattedTime() публичный статический Метод

Returns the time as a formatted string or as a table if no format is given.
public static FormattedTime ( LuaState luaState, double @float, string format ) : string
luaState LuaState Pointer to lua_State struct.
@float double
format string An optional formatting to use. If no format it specified, a table will be returned instead.
Результат string

GetExtensionFromFilename() публичный статический Метод

Returns extension of the file.
public static GetExtensionFromFilename ( LuaState luaState, string fileName ) : string
luaState LuaState Pointer to lua_State struct.
fileName string String e.g. file-path to get the file extensions from.
Результат string

GetFileFromFilename() публичный статический Метод

Returns file name and extension.
public static GetFileFromFilename ( LuaState luaState, string fileName ) : string
luaState LuaState Pointer to lua_State struct.
fileName string The string e.g. file-path to get the file-name from.
Результат string

GetPathFromFilename() публичный статический Метод

Returns the path only from a file's path.
public static GetPathFromFilename ( LuaState luaState, string fileName ) : string
luaState LuaState Pointer to lua_State struct.
fileName string String to get path from.
Результат string

JavascriptSafe() публичный статический Метод

Escapes special characters for JavaScript in a string, making the string safe for inclusion in to JavaScript strings.
public static JavascriptSafe ( LuaState luaState, string inputString ) : string
luaState LuaState Pointer to lua_State struct.
inputString string The string that should be escaped.
Результат string

Left() публичный статический Метод

Returns everything left of supplied place of inputString.
public static Left ( LuaState luaState, string inputString, uint num ) : string
luaState LuaState Pointer to lua_State struct.
inputString string The string to extract from.
num uint Amount of chars relative to the beginning (starting from 1).
Результат string

NiceSize() публичный статический Метод

Converts supplied number into bytes.
public static NiceSize ( LuaState luaState, uint bytes ) : string
luaState LuaState Pointer to lua_State struct.
bytes uint The number to convert into bytes.
Результат string

NiceTime() публичный статический Метод

Converts supplied number into string.
public static NiceTime ( LuaState luaState, uint seconds ) : string
luaState LuaState Pointer to lua_State struct.
seconds uint The number to convert into string.
Результат string

PatternSafe() публичный статический Метод

Escapes all special characters within a string, making the string safe for inclusion in a Lua pattern.
public static PatternSafe ( LuaState luaState, string inputString ) : string
luaState LuaState Pointer to lua_State struct.
inputString string The string to be sanitized.
Результат string

Replace() публичный статический Метод

Replaces all occurrences of the supplied second string.
public static Replace ( LuaState luaState, string input, string find, string replace ) : string
luaState LuaState Pointer to lua_State struct.
input string The string we are seeking to replace an occurrence(s).
find string What we are seeking to replace.
replace string What to replace find with.
Результат string

Right() публичный статический Метод

Returns the last n-th characters of the string.
public static Right ( LuaState luaState, string inputString, uint num ) : string
luaState LuaState Pointer to lua_State struct.
inputString string The string to extract from.
num uint Amount of chars relative to the end (starting from 1).
Результат string

SetChar() публичный статический Метод

Sets the character at the specific index of the string.
public static SetChar ( LuaState luaState, string inputString, uint index, char replacement ) : string
luaState LuaState Pointer to lua_State struct.
inputString string The input string.
index uint The character index, 1 is the first from left.
replacement char String to replace with.
Результат string

StartWith() публичный статический Метод

Returns whether or not the first string starts with the second.
public static StartWith ( LuaState luaState, string inputString, string startString ) : bool
luaState LuaState Pointer to lua_State struct.
inputString string String to check.
startString string String to check with.
Результат bool

StripExtension() публичный статический Метод

Removes the extension of a path.
public static StripExtension ( LuaState luaState, string fileName ) : string
luaState LuaState Pointer to lua_State struct.
fileName string The path to change.
Результат string

ToMinutesSeconds() публичный статический Метод

Returns the given time in "MM:SS" format.
public static ToMinutesSeconds ( LuaState luaState, uint time ) : string
luaState LuaState Pointer to lua_State struct.
time uint Time in seconds.
Результат string

ToMinutesSecondsMilliseconds() публичный статический Метод

Returns the given time in "MM:SS:MS" format.
public static ToMinutesSecondsMilliseconds ( LuaState luaState, double time ) : string
luaState LuaState Pointer to lua_State struct.
time double Time in seconds.
Результат string

Trim() публичный статический Метод

Removes leading and trailing matches of a string.
public static Trim ( LuaState luaState, string inputString, string match = " " ) : string
luaState LuaState Pointer to lua_State struct.
inputString string The string to trim.
match string String to match.
Результат string

TrimLeft() публичный статический Метод

Removes leading spaces/characters from a string.
public static TrimLeft ( LuaState luaState, string inputString, string match = " " ) : string
luaState LuaState Pointer to lua_State struct.
inputString string String to trim.
match string Character to remove.
Результат string

TrimRight() публичный статический Метод

Removes trailing spaces/passed character from a string.
public static TrimRight ( LuaState luaState, string inputString, string match = " " ) : string
luaState LuaState Pointer to lua_State struct.
inputString string String to remove from.
match string Character to remove.
Результат string

find() публичный статический Метод

Attempts to find the specified substring in a string, uses patterns by default.
public static find ( LuaState luaState, string hayStack, string needle, int startPos = 1, bool noPatterns = false ) : int>.Tuple
luaState LuaState Pointer to lua_State struct.
hayStack string The string to search in.
needle string The string to find, can contain patterns if enabled.
startPos int /// The position to start the search from, can be negative start position will be relative to the /// end position. ///
noPatterns bool Set to true to disable patterns.
Результат int>.Tuple

find() публичный статический Метод

Attempts to find the specified substring in a string, uses patterns by default.
public static find ( LuaState luaState, int &start, int &end, string hayStack, string needle, int startPos = 1, bool noPatterns = false ) : void
luaState LuaState Pointer to lua_State struct.
start int Starting position of the found text.
end int Ending position of found text.
hayStack string The string to search in.
needle string The string to find, can contain patterns if enabled.
startPos int /// The position to start the search from, can be negative start position will be relative to the /// end position. ///
noPatterns bool Set to true to disable patterns.
Результат void

format() публичный статический Метод

Formats the specified values into the string given.
public static format ( LuaState luaState, string inputString ) : string
luaState LuaState Pointer to lua_State struct.
inputString string The string to be formatted. /// /// Follows this format. ///
Результат string

gsub() публичный статический Метод

This functions main purpose is to replace certain character sequences in a string using patterns.
public static gsub ( LuaState luaState, string input, string pattern, string replacement, uint maxReplaces = default(uint) ) : uint>.Tuple
luaState LuaState Pointer to lua_State struct.
input string String which should be modified.
pattern string The pattern that defines what should be matched and eventually be replaced.
replacement string /// In case of a string the matches sequence will be replaced with it. /// /// In case of a table, the matched sequence will be used as key and the table will tested for the key, if a value /// exists it will be used as replacement. /// /// In case of a function all matches will be passed as parameters to the function, the return value(s) of the function /// will then be used as replacement. ///
maxReplaces uint Maximum number of replacements to be made.
Результат uint>.Tuple

gsub() публичный статический Метод

This functions main purpose is to replace certain character sequences in a string using patterns.
public static gsub ( LuaState luaState, string &replaceResult, uint &replaceCount, string input, string pattern, string replacement, uint maxReplaces = default(uint) ) : void
luaState LuaState Pointer to lua_State struct.
replaceResult string Replaced string.
replaceCount uint Number of replaces.
input string String which should be modified.
pattern string The pattern that defines what should be matched and eventually be replaced.
replacement string /// In case of a string the matches sequence will be replaced with it. /// /// In case of a table, the matched sequence will be used as key and the table will tested for the key, if a value /// exists it will be used as replacement. /// /// In case of a function all matches will be passed as parameters to the function, the return value(s) of the function /// will then be used as replacement. ///
maxReplaces uint Maximum number of replacements to be made.
Результат void

len() публичный статический Метод

Counts the number of characters in the string (length).
public static len ( LuaState luaState, string inputString ) : uint
luaState LuaState Pointer to lua_State struct.
inputString string The string to find the length of.
Результат uint

lower() публичный статический Метод

Changes any upper-case letters in a inputString to lower-case letters.
public static lower ( LuaState luaState, string inputString ) : string
luaState LuaState Pointer to lua_State struct.
inputString string The string to convert.
Результат string

match() публичный статический Метод

Finds a http://wiki.garrysmod.com/page/Patterns">pattern in a
public static match ( LuaState luaState, string inputString, string pattern, int startPosition ) : string
luaState LuaState Pointer to lua_State struct.
inputString string String which should be searched in for matches.
pattern string The pattern that defines what should be matched.
startPosition int /// The start index to start the matching from, can be negative to start the match from a /// position relative to the end. ///
Результат string

rep() публичный статический Метод

Repeats a string by the given value.
public static rep ( LuaState luaState, string inputString, uint repetitions ) : string
luaState LuaState Pointer to lua_State struct.
inputString string The string to repeat.
repetitions uint How many times to repeat.
Результат string

reverse() публичный статический Метод

Reverses a string.
public static reverse ( LuaState luaState, string inputString ) : string
luaState LuaState Pointer to lua_State struct.
inputString string The string to be reversed.
Результат string

sub() публичный статический Метод

Returns a sub-string, starting from the character at position startPos of the string (inclusive), and optionally ending at the character at position endPos of the string (also inclusive). If endPos is not given, the rest of the string is returned.
public static sub ( LuaState luaState, string inputString, uint startPos, uint endPos = default(uint) ) : string
luaState LuaState Pointer to lua_State struct.
inputString string The string you'll take a sub-string out of.
startPos uint The position of the first character that will be included in the sub-string.
endPos uint The position of the last character to be included in the sub-string.
Результат string

upper() публичный статический Метод

Changes any lower-case letters in a string to upper-case letters.
public static upper ( LuaState luaState, string inputString ) : string
luaState LuaState Pointer to lua_State struct.
inputString string The string to convert.
Результат string