[Include] TDW String Library
#1

TDW String Library
github
Description:
This library adds new functions to work with strings. All functions supports the packed strings!
Functions:

Erase:

erase_first(string[], const find[], bool:ignorecase = false, pos = 0);
Description:
Remove the first occurrence of the substring from the string.
Returns:
The beginning Position of the substring in the string.
erase_last(string[], const find[], bool:ignorecase = false);
Description:
Remove the last occurrence of the substring from the string.
Returns:
The beginning Position of the substring in the string.
erase_nth(string[], const find[], n, bool:ignorecase = false, pos = 0);
Description:
Remove the Nth occurrence of the substring in the string.
Returns:
-1
erase(string[], start_pos, length = cellmax);
Description:
Remove the part of the substring in the string.
Returns:
-1


Find:

find_first(const string[], const find[], bool:ignorecase = false, pos = 0);
Description:
Search for a substring(find) in the string.
Returns:
The beginning position of the substring in the string, otherwise -1
find_last(const string[], const find[], bool:ignorecase = false);
Description:
Search for the last occurrence of a substring(find) in the string.
Returns:
The beginning position of the substring in the string, otherwise -1
find_first_of(const string[], const charlist[], pos_string = 0, size = sizeof string);
Description:
Search for the symbol from the array(charlist) in the string.
Returns:
The position of the first character in the string, otherwise -1
find_last_of(const string[], const charlist[]);
Description:
Search for the symbol from the array(charlist) from the end of the string.
Returns:
The position of the first character from the end of the string, otherwise -1
find_first_not_of(const string[], const charlist[], pos_string = 0, size = sizeof string);
Description:
Search for the first symbol not from the array(charlist) in the string.
Returns:
The position in the string, otherwise -1
find_last_not_of(const string[], const charlist[]);
Description:
Search for the first symbol not from the array(charlist) from the end of the string.
Returns:
The position in the string, otherwise -1

Replace:

replace_first(string[], const find[], const replace[], bool:ignorecase = false, pos = 0, string_size = sizeof string);
Description:
Replace the first occurrence of a substring(find) string(replace).
Returns:
If the string is found, 1, otherwise 0.
replace_last(string[], const find[], const replace[], bool:ignorecase = false, pos = 0, string_size = sizeof string);
Description:
Replace the last occurrence of a substring(find) string(replace).
Returns:
If the string is found, 1, otherwise 0.
replace_nth(string[], const find[], const replace[], n, bool:ignorecase = false, pos = 0, string_size = sizeof string);
Description:
Replace the Nth occurrence of the substring in the string.
Returns:
If the string is found, 1, otherwise 0.
replace_all(string[], const find[], const replace[], bool:ignorecase = false, pos = 0, string_size = sizeof string);
Description:
Replace all substring in the string
Returns:
If the string is found, 1, otherwise 0.

Trim:

trim_left(string[], const delimiter = ' ');
Description:
Remove all leading spaces from the string.
Returns:
-
trim_right(string[], const delimiter = ' ');
Description:
Remove all trailing spaces from the string.
Returns:
-
trim(string[], const delimiter = ' ');
Description:
Remove all both spaces from the string.
Returns:
-
trim_leftex(string[], const delimiters = !" ");
Description:
Remove all leading spaces from the string.
Returns:
-
trim_rightex(string[], const delimiters = !" ");
Description:
Remove all trailing spaces from the string.
Returns:
-
trim_ex(string[], const delimiters = !" ");
Description:
Remove all both spaces from the string.
Returns:
-

Useful:

IsEmptyString(const string[]);
Description:
Find out if a string is empty.
Returns:
Returns true if the string is empty, otherwise false
strcount(const string[], const find[], bool:ignorecase = false, pos = 0, string_size = sizeof string);
Description:
Counts the number of substrings(find) in the string.
Returns:
The number of nested substrings
strreverse(string[]);
Description:
Reverses the string.
Returns:
-
strparttoupper(string[], part_start, part_end, string_size = sizeof string);
Description:
This function changes lowercase letters to uppercase in the string.
Returns:
-
strparttolower(string[], part_start, part_end, string_size = sizeof string);
Description:
This function changes all uppercase to lowercase letters in the string.
Returns:
-
countofuppercase(const string[]);
Description:
Count the number of uppercase letters in the string.
Returns:
a number (percentage)
countoflowpercase(const string[]);
Description:
Count the number of lowercase letters in the string.
Returns:
a number (percentage)
strtrtrans(string[]);
Description:
Translate Russian characters in the transliteration.
Returns:
-
islowerpart(const string[], start_part_pos, end_part_pos);
Description:
Checks the string part on the content of the lowercase characters.
Returns:
Returns true, otherwise false
isupperpart(const string[], start_part_pos, end_part_pos);
Description:
Checks the string part on the content of the uppercase characters.
Returns:
Returns true, otherwise false
strcatex(dest[], size, const ...);
Description:
Concatenate the strings to each other by means of strcat.
Returns:
Returns the number of characters.
strfill(string[], const pattern[] = " ", fill_length, E_TDW_FILL_TYPE:type = FILL_TYPE_BOTH, size = sizeof string);
Description:
Fill a string with the specified substring.
Returns:
Returns 1 if fill_length less than size, otherwise 0.
strimplodeex(dest[], const delimiter[] = !" ", dest_size = sizeof dest, const ...);
Description:
Fill in string with a separator(delimiter).
Returns:
The number of characters (without separators).
strimplode(dest[], const arrays[][], const delimiter[] = !" ", array_items = sizeof arrays, dest_size = sizeof dest);
Description:
Same as strimplodeex, however, the values from the array.
Returns:
-
strsplit(dest[], const string[], &index, const seperator = ' ');
Description:
The similarity strtok, but in a better form. Note: doesn't work with the packed strings.
Returns:
-
replace_symbol(string[], const _char, replace, pos = 0);
Description:
Replace a single character in the string.
Returns:
-
replace_symbols(string[], const _char, replace, pos = 0);
Description:
Replace the characters in the string.
Returns:
-
Download:
github
Installation:
  1. Download it!
  2. Copy all files to the folder '/pawno/include' which is located in the folder with the server.
  3. The library need to include after the SAMP libraries.
    Example:
    pawn Code:
    #include <a_samp>
    #include <tdw_string>
  4. Compile the modified scripts!
Thanks:
  • Untonyst
  • Nexius
  • ziggi
  • DeimoS
  • Stepashka
Licensed under the ZLIB.
Reply


Messages In This Thread
TDW String Library - by VVWVV - 27.11.2016, 22:21
Re: TDW String Library - by Ivan_Ino - 27.11.2016, 22:27
Re: TDW String Library - by Jelly23 - 28.11.2016, 00:10
Re: TDW String Library - by VVWVV - 28.11.2016, 12:35
Re: TDW String Library - by VVWVV - 30.11.2016, 11:18
Re: TDW String Library - by iamjems - 30.11.2016, 15:03
Re: TDW String Library - by RyderX - 01.12.2016, 19:52

Forum Jump:


Users browsing this thread: 2 Guest(s)