unreal.StringLibrary

class unreal.StringLibrary(outer=None, name='None')

Bases: unreal.BlueprintFunctionLibrary

Kismet String Library

C++ Source:

  • Module: Engine

  • File: KismetStringLibrary.h

classmethod build_string_bool(append_to, prefix, bool, suffix) str

Converts a boolean->string, creating a new string in the form AppendTo+Prefix+InBool+Suffix

Parameters
  • append_to (str) – An existing string to use as the start of the conversion string

  • prefix (str) – A string to use as a prefix, after the AppendTo string

  • bool (bool) – The bool value to convert. Will add “true” or “false” to the conversion string

  • suffix (str) – A suffix to append to the end of the conversion string

Returns

A new string built from the passed parameters

Return type

str

classmethod build_string_color(append_to, prefix, color, suffix) str

Converts a color->string, creating a new string in the form AppendTo+Prefix+InColor+Suffix

Parameters
  • append_to (str) – An existing string to use as the start of the conversion string

  • prefix (str) – A string to use as a prefix, after the AppendTo string

  • color (LinearColor) – The linear color value to convert. Uses the standard ToString conversion

  • suffix (str) – A suffix to append to the end of the conversion string

Returns

A new string built from the passed parameters

Return type

str

classmethod build_string_double(append_to, prefix, double, suffix) str

Converts a double->string, create a new string in the form AppendTo+Prefix+InDouble+Suffix

Parameters
  • append_to (str) – An existing string to use as the start of the conversion string

  • prefix (str) – A string to use as a prefix, after the AppendTo string

  • double (double) – The double value to convert

  • suffix (str) – A suffix to append to the end of the conversion string

Returns

A new string built from the passed parameters

Return type

str

classmethod build_string_float(append_to, prefix, double, suffix)

deprecated: ‘build_string_float’ was renamed to ‘build_string_double’.

classmethod build_string_int(append_to, prefix, int, suffix) str

Converts a int->string, creating a new string in the form AppendTo+Prefix+InInt+Suffix

Parameters
  • append_to (str) – An existing string to use as the start of the conversion string

  • prefix (str) – A string to use as a prefix, after the AppendTo string

  • int (int32) – The int value to convert

  • suffix (str) – A suffix to append to the end of the conversion string

Returns

A new string built from the passed parameters

Return type

str

classmethod build_string_int_vector(append_to, prefix, int_vector, suffix) str

Converts an IntVector->string, creating a new string in the form AppendTo+Prefix+InIntVector+Suffix

Parameters
  • append_to (str) – An existing string to use as the start of the conversion string

  • prefix (str) – A string to use as a prefix, after the AppendTo string

  • int_vector (IntVector) – The intVector value to convert. Uses the standard FVector::ToString conversion

  • suffix (str) – A suffix to append to the end of the conversion string

Returns

A new string built from the passed parameters

Return type

str

classmethod build_string_name(append_to, prefix, name, suffix) str

Converts a color->string, creating a new string in the form AppendTo+Prefix+InName+Suffix

Parameters
  • append_to (str) – An existing string to use as the start of the conversion string

  • prefix (str) – A string to use as a prefix, after the AppendTo string

  • name (Name) – The name value to convert

  • suffix (str) – A suffix to append to the end of the conversion string

Returns

A new string built from the passed parameters

Return type

str

classmethod build_string_object(append_to, prefix, obj, suffix) str

Converts a object->string, creating a new string in the form AppendTo+Prefix+object name+Suffix

Parameters
  • append_to (str) – An existing string to use as the start of the conversion string

  • prefix (str) – A string to use as a prefix, after the AppendTo string

  • obj (Object) – The object to convert. Will insert the name of the object into the conversion string

  • suffix (str) – A suffix to append to the end of the conversion string

Returns

A new string built from the passed parameters

Return type

str

classmethod build_string_rotator(append_to, prefix, rot, suffix) str

Converts a rotator->string, creating a new string in the form AppendTo+Prefix+InRot+Suffix

Parameters
  • append_to (str) – An existing string to use as the start of the conversion string

  • prefix (str) – A string to use as a prefix, after the AppendTo string

  • rot (Rotator) – The rotator value to convert. Uses the standard ToString conversion

  • suffix (str) – A suffix to append to the end of the conversion string

Returns

A new string built from the passed parameters

Return type

str

classmethod build_string_vector(append_to, prefix, vector, suffix) str

Converts a vector->string, creating a new string in the form AppendTo+Prefix+InVector+Suffix

Parameters
  • append_to (str) – An existing string to use as the start of the conversion string

  • prefix (str) – A string to use as a prefix, after the AppendTo string

  • vector (Vector) – The vector value to convert. Uses the standard FVector::ToString conversion

  • suffix (str) – A suffix to append to the end of the conversion string

Returns

A new string built from the passed parameters

Return type

str

classmethod build_string_vector2d(append_to, prefix, vector2d, suffix) str

Converts a vector2d->string, creating a new string in the form AppendTo+Prefix+InVector2d+Suffix

Parameters
  • append_to (str) – An existing string to use as the start of the conversion string

  • prefix (str) – A string to use as a prefix, after the AppendTo string

  • vector2d (Vector2D) – The vector2d value to convert. Uses the standard FVector2D::ToString conversion

  • suffix (str) – A suffix to append to the end of the conversion string

Returns

A new string built from the passed parameters

Return type

str

classmethod concat_str_str(a, b) str

Concatenates two strings together to make a new string

Parameters
  • a (str) – The original string

  • b (str) – The string to append to A

Returns

A new string which is the concatenation of A+B

Return type

str

classmethod contains(search_in, substring, use_case=False, search_from_end=False) bool

Returns whether this string contains the specified substring.

Parameters
  • search_in (str) –

  • substring (str) –

  • use_case (bool) –

  • search_from_end (bool) –

Returns

Returns whether the string contains the substring

Return type

bool

classmethod conv_bool_to_string(bool) str

Converts a boolean value to a string, either ‘true’ or ‘false’

Parameters

bool (bool) –

Return type

str

classmethod conv_byte_to_string(byte) str

Converts a byte value to a string

Parameters

byte (uint8) –

Return type

str

classmethod conv_color_to_string(color) str

Converts a linear color value to a string, in the form ‘(R=,G=,B=,A=)’

Parameters

color (LinearColor) –

Return type

str

classmethod conv_double_to_string(double) str

Converts a double value to a string

Parameters

double (double) –

Return type

str

classmethod conv_float_to_string(double)

deprecated: ‘conv_float_to_string’ was renamed to ‘conv_double_to_string’.

classmethod conv_int64_to_string(int) str

Converts an 64-bit integer value to a string

Parameters

int (int64) –

Return type

str

classmethod conv_int_point_to_string(int_point) str

Converts an IntPoint value to a string, in the form ‘X= Y=’

Parameters

int_point (IntPoint) –

Return type

str

classmethod conv_int_to_string(int) str

Converts an integer value to a string

Parameters

int (int32) –

Return type

str

classmethod conv_int_vector_to_string(int_vec) str

Converts an IntVector value to a string, in the form ‘X= Y= Z=’

Parameters

int_vec (IntVector) –

Return type

str

classmethod conv_matrix_to_string(matrix) str

Converts a name value to a string

Parameters

matrix (Matrix) –

Return type

str

classmethod conv_name_to_string(name) str

Converts a name value to a string

Parameters

name (Name) –

Return type

str

classmethod conv_object_to_string(obj) str

Converts a UObject value to a string by calling the object’s GetName method

Parameters

obj (Object) –

Return type

str

classmethod conv_rotator_to_string(rot) str

Converts a rotator value to a string, in the form ‘P= Y= R=’

Parameters

rot (Rotator) –

Return type

str

classmethod conv_string_to_color(string) -> (out_converted_color=LinearColor, out_is_valid=bool)

Convert String Back To Color. IsValid indicates whether or not the string could be successfully converted.

Parameters

string (str) –

Returns

out_converted_color (LinearColor):

out_is_valid (bool):

Return type

tuple

classmethod conv_string_to_double(string) double

Converts a string to a double value

Parameters

string (str) –

Return type

double

classmethod conv_string_to_float(string)

deprecated: ‘conv_string_to_float’ was renamed to ‘conv_string_to_double’.

classmethod conv_string_to_int(string) int32

Converts a string to a int value

Parameters

string (str) –

Return type

int32

classmethod conv_string_to_name(string) Name

Converts a string to a name value

Parameters

string (str) –

Return type

Name

classmethod conv_string_to_rotator(string) -> (out_converted_rotator=Rotator, out_is_valid=bool)

Convert String Back To Rotator. IsValid indicates whether or not the string could be successfully converted.

Parameters

string (str) –

Returns

out_converted_rotator (Rotator):

out_is_valid (bool):

Return type

tuple

classmethod conv_string_to_vector(string) -> (out_converted_vector=Vector, out_is_valid=bool)

Convert String Back To Vector. IsValid indicates whether or not the string could be successfully converted.

Parameters

string (str) –

Returns

out_converted_vector (Vector):

out_is_valid (bool):

Return type

tuple

classmethod conv_string_to_vector2d(string) -> (out_converted_vector2d=Vector2D, out_is_valid=bool)

Convert String Back To Vector2D. IsValid indicates whether or not the string could be successfully converted.

Parameters

string (str) –

Returns

out_converted_vector2d (Vector2D):

out_is_valid (bool):

Return type

tuple

classmethod conv_string_to_vector3f(string) -> (out_converted_vector=Vector3f, out_is_valid=bool)

Convert String Back To Float Vector. IsValid indicates whether or not the string could be successfully converted.

Parameters

string (str) –

Returns

out_converted_vector (Vector3f):

out_is_valid (bool):

Return type

tuple

classmethod conv_transform_to_string(trans) str

Converts a transform value to a string, in the form ‘Translation: X= Y= Z= Rotation: P= Y= R= Scale: X= Y= Z=’

Parameters

trans (Transform) –

Return type

str

classmethod conv_vector2d_to_string(vec) str

Converts a vector2d value to a string, in the form ‘X= Y=’

Parameters

vec (Vector2D) –

Return type

str

classmethod conv_vector3f_to_string(vec) str

Converts a float vector value to a string, in the form ‘X= Y= Z=’

Parameters

vec (Vector3f) –

Return type

str

classmethod conv_vector_to_string(vec) str

Converts a vector value to a string, in the form ‘X= Y= Z=’

Parameters

vec (Vector) –

Return type

str

classmethod cull_array(source_string) -> (int32, array=Array(str))

Takes an array of strings and removes any zero length entries.

Parameters

source_string (str) –

Returns

The number of elements left in InArray

array (Array(str)): The array to cull

Return type

Array(str)

classmethod ends_with(source_string, suffix, search_case=SearchCase.IGNORE_CASE) bool

Test whether this string ends with given string.

Parameters
  • source_string (str) –

  • suffix (str) –

  • search_case (SearchCase) – Indicates whether the search is case sensitive or not ( defaults to ESearchCase::IgnoreCase )

Returns

true if this string ends with specified text, false otherwise

Return type

bool

classmethod equal_equal_str_str(a, b) bool

Test if the input strings are equal (A == B)

Parameters
  • a (str) – The string to compare against

  • b (str) – The string to compare

Returns

True if the strings are equal, false otherwise

Return type

bool

classmethod equal_equal_stri_stri(a, b) bool

Test if the input strings are equal (A == B), ignoring case

Parameters
  • a (str) – The string to compare against

  • b (str) – The string to compare

Returns

True if the strings are equal, false otherwise

Return type

bool

classmethod find_substring(search_in, substring, use_case=False, search_from_end=False, start_position=- 1) int32

Finds the starting index of a substring in the a specified string

Parameters
  • search_in (str) – The string to search within

  • substring (str) – The string to look for in the SearchIn string

  • use_case (bool) – Whether or not to be case-sensitive

  • search_from_end (bool) – Whether or not to start the search from the end of the string instead of the beginning

  • start_position (int32) – The position to start the search from

Returns

The index (starting from 0 if bSearchFromEnd is false) of the first occurence of the substring

Return type

int32

classmethod get_character_array_from_string(source_string)

Returns an array that contains one entry for each character in SourceString

Parameters

source_string (str) – The string to break apart into characters

Returns

An array containing one entry for each character in SourceString

Return type

Array(str)

classmethod get_character_as_number(source_string, index=0) int32

Gets a single character from the string (as an integer)

Parameters
  • source_string (str) – The string to convert

  • index (int32) – Location of the character whose value is required

Returns

The integer value of the character or 0 if index is out of range

Return type

int32

classmethod get_substring(source_string, start_index=0, length=1) str

Returns a substring from the string starting at the specified position

Parameters
  • source_string (str) – The string to get the substring from

  • start_index (int32) – The location in SourceString to use as the start of the substring

  • length (int32) – The length of the requested substring

Returns

The requested substring

Return type

str

classmethod is_empty(string) bool

Returns true if the string is empty

Parameters

string (str) – The string to check

Returns

Whether or not the string is empty

Return type

bool

classmethod is_numeric(source_string) bool
  • Checks if a string contains only numeric characters

Parameters

source_string (str) – The string to check *

Returns

true if the string only contains numeric characters

Return type

bool

classmethod join_string_array(source_array, separator=' ') str

Concatenates an array of strings into a single string.

Parameters
  • source_array (Array(str)) – The array of strings to concatenate.

  • separator (str) – The string used to separate each element.

Returns

The final, joined, separated string.

Return type

str

classmethod left(source_string, count) str

Returns the left most given number of characters

Parameters
  • source_string (str) –

  • count (int32) –

Return type

str

classmethod left_chop(source_string, count) str

Returns the left most characters from the string chopping the given number of characters from the end

Parameters
  • source_string (str) –

  • count (int32) –

Return type

str

classmethod left_pad(source_string, ch_count) str
  • Pad the left of this string for a specified number of characters

Parameters
  • source_string (str) – The string to pad *

  • ch_count (int32) – Amount of padding required *

Returns

The padded string

Return type

str

classmethod len(s) int32

Returns the number of characters in the string

Parameters

s (str) –

Returns

The number of chars in the string

Return type

int32

classmethod matches_wildcard(source_string, wildcard, search_case=SearchCase.IGNORE_CASE) bool

Searches this string for a given wild card warning: This is a simple, SLOW routine. Use with caution

Parameters
  • source_string (str) –

  • wildcard (str) – *?-type wildcard

  • search_case (SearchCase) – Indicates whether the search is case sensitive or not ( defaults to ESearchCase::IgnoreCase )

Returns

true if this string matches the *?-type wildcard given.

Return type

bool

classmethod mid(source_string, start, count) str

Returns the substring from Start position for Count characters.

Parameters
  • source_string (str) –

  • start (int32) –

  • count (int32) –

Return type

str

classmethod not_equal_str_str(a, b) bool

Test if the input string are not equal (A != B)

Parameters
  • a (str) – The string to compare against

  • b (str) – The string to compare

Returns

Returns true if the input strings are not equal, false if they are equal

Return type

bool

classmethod not_equal_stri_stri(a, b) bool

Test if the input string are not equal (A != B), ignoring case differences

Parameters
  • a (str) – The string to compare against

  • b (str) – The string to compare

Returns

Returns true if the input strings are not equal, false if they are equal

Return type

bool

classmethod parse_into_array(source_string, delimiter=' ', cull_empty_strings=True)

Gets an array of strings from a source string divided up by a separator and empty strings can optionally be culled.

Parameters
  • source_string (str) – The string to chop up

  • delimiter (str) – The string to delimit on

  • cull_empty_strings (bool) – = true - Cull (true) empty strings or add them to the array (false)

Returns

The array of string that have been separated

Return type

Array(str)

classmethod replace(source_string, from_, to, search_case=SearchCase.IGNORE_CASE) str

Replace all occurrences of a substring in this string

Parameters
  • source_string (str) –

  • from (str) – substring to replace

  • to (str) – substring to replace From with

  • search_case (SearchCase) – Indicates whether the search is case sensitive or not ( defaults to ESearchCase::IgnoreCase )

Returns

a copy of this string with the replacement made

Return type

str

classmethod replace_inline(source_string, search_text, replacement_text, search_case=SearchCase.IGNORE_CASE) -> (int32, source_string=str)

Replace all occurrences of SearchText with ReplacementText in this string.

Parameters
  • source_string (str) –

  • search_text (str) – the text that should be removed from this string

  • replacement_text (str) – the text to insert in its place

  • search_case (SearchCase) – Indicates whether the search is case sensitive or not ( defaults to ESearchCase::IgnoreCase )

Returns

the number of occurrences of SearchText that were replaced.

source_string (str):

Return type

str

classmethod reverse(source_string) str

Returns a copy of this string, with the characters in reverse order

Parameters

source_string (str) –

Return type

str

classmethod right(source_string, count) str

Returns the string to the right of the specified location, counting back from the right (end of the word).

Parameters
  • source_string (str) –

  • count (int32) –

Return type

str

classmethod right_chop(source_string, count) str

Returns the string to the right of the specified location, counting forward from the left (from the beginning of the word).

Parameters
  • source_string (str) –

  • count (int32) –

Return type

str

classmethod right_pad(source_string, ch_count) str
  • Pad the right of this string for a specified number of characters

Parameters
  • source_string (str) – The string to pad *

  • ch_count (int32) – Amount of padding required *

Returns

The padded string

Return type

str

classmethod split(source_string, str, search_case=SearchCase.IGNORE_CASE, search_dir=SearchDir.FROM_START) (left_s=str, right_s=str) or None

Splits this string at given string position case sensitive.

Parameters
  • source_string (str) –

  • str (str) – The string to search and split at

  • search_case (SearchCase) – Indicates whether the search is case sensitive or not ( defaults to ESearchCase::IgnoreCase )

  • search_dir (SearchDir) – Indicates whether the search starts at the begining or at the end ( defaults to ESearchDir::FromStart )

Returns

true if string is split, otherwise false

left_s (str): out the string to the left of InStr, not updated if return is false

right_s (str): out the string to the right of InStr, not updated if return is false

Return type

tuple or None

classmethod starts_with(source_string, prefix, search_case=SearchCase.IGNORE_CASE) bool

Test whether this string starts with given string.

Parameters
  • source_string (str) –

  • prefix (str) –

  • search_case (SearchCase) – Indicates whether the search is case sensitive or not ( defaults to ESearchCase::IgnoreCase )

Returns

true if this string begins with specified text, false otherwise

Return type

bool

classmethod time_seconds_to_string(seconds) str

Convert a number of seconds into minutes:seconds.milliseconds format string (including leading zeroes)

Parameters

seconds (float) –

Returns

A new string built from the seconds parameter

Return type

str

classmethod to_lower(source_string) str

Returns a string converted to Lower case

Parameters

source_string (str) – The string to convert

Returns

The string in lower case

Return type

str

classmethod to_upper(source_string) str

Returns a string converted to Upper case

Parameters

source_string (str) – The string to convert

Returns

The string in upper case

Return type

str

classmethod trim(source_string) str

Removes whitespace characters from the front of this string.

Parameters

source_string (str) –

Return type

str

classmethod trim_trailing(source_string) str

Removes trailing whitespace characters

Parameters

source_string (str) –

Return type

str