MUDBRINGER
Menu

String Manipulation

P_concat

Syntax

@concat({arg1}, {arg2}, ...)

Use Case:

Joins multiple strings together into a single string.

Arguments:

  • {args}: One or more strings to concatenate.

Examples:

  1. /echo {@concat(Hello, , World)}

See Also:

math

P_left

Syntax

@left({text}, {len})

Use Case:

Returns the specified number of characters from the left side of a string.

Arguments:

  • {text}: The string to slice.
  • {len} : Number of characters to take.

Examples:

  1. /echo {@left(MudBringer, 3)} (Outputs ‘Mud’)

See Also:

@right, @mid

P_len

Syntax

@len({text})

Use Case:

Returns the total number of characters in a string.

Arguments:

  • {text}: The string to measure.

Examples:

  1. /echo {Length is: @len(hello world)}

See Also:

@substr, @mid

P_lower

Syntax

@lower({text})

Use Case:

Converts all characters in a string to lowercase.

Arguments:

  • {text}: The input text.

Examples:

  1. /echo {@lower(HELLO)}

See Also:

@upper

P_leftpad

Syntax

@leftpad({text}, {char}, {total})

Use Case:

Pads the left side of a string until it reaches a specific total length.

Arguments:

  • {text} : The input string.
  • {char} : The character to use for padding.
  • {total}: The desired total length.

Examples:

  1. /echo {@leftpad(Mud, ., 10)} (Outputs ‘…….Mud’)

See Also:

@rightpad, @padleft

P_ltrim

Syntax

@ltrim({text})

Use Case:

Removes only the leading (left-side) whitespace from a string.

Arguments:

  • {text}: The input text.

Examples:

  1. /echo {@ltrim( start)}

See Also:

@rtrim, @trim

P_mid

Syntax

@mid({text}, {start}, {len})

Use Case:

Returns a substring of a specific length, starting at a given position (0-indexed).

Arguments:

  • {text} : The string to slice.
  • {start}: Starting index (0 is first char).
  • {len} : Number of characters to take.

Examples:

  1. /echo {@mid(MudBringer, 3, 4)} (Outputs ‘Flin’)

See Also:

@left, @right, @substr

P_padleft

Syntax

@padleft({text}, {char}, {count})

Use Case:

Adds a specific number of padding characters to the left side of a string.

Arguments:

  • {text} : The input string.
  • {char} : The character to use for padding.
  • {count}: How many characters to add.

Examples:

  1. /echo {@padleft(100, 0, 2)} (Outputs ‘00100’)

See Also:

@padright, @leftpad

P_padright

Syntax

@padright({text}, {char}, {count})

Use Case:

Adds a specific number of padding characters to the right side of a string.

Arguments:

  • {text} : The input string.
  • {char} : The character to use for padding.
  • {count}: How many characters to add.

Examples:

  1. /echo {@padright(Mud, !, 3)} (Outputs ‘Mud!!!’)

See Also:

@padleft, @rightpad

P_replace

Syntax

@replace({text}, {old}, {new})

Use Case:

Replaces all occurrences of a specific substring with a new value.

Arguments:

  • {text}: The original string.
  • {old} : The substring to find.
  • {new} : The replacement value.

Examples:

  1. /echo {@replace(I like cats, cats, dogs)} (Outputs ‘I like dogs’)

See Also:

@math

P_right

Syntax

@right({text}, {len})

Use Case:

Returns the specified number of characters from the right side of a string.

Arguments:

  • {text}: The string to slice.
  • {len} : Number of characters to take.

Examples:

  1. /echo {@right(MudBringer, 7)} (Outputs ‘Flinger’)

See Also:

@left, @mid

P_rightpad

Syntax

@rightpad({text}, {char}, {total})

Use Case:

Pads the right side of a string until it reaches a specific total length.

Arguments:

  • {text} : The input string.
  • {char} : The character to use for padding.
  • {total}: The desired total length.

Examples:

  1. /echo {@rightpad(Mud, ., 10)} (Outputs ‘Mud…….’)

See Also:

@leftpad, @padright

P_rtrim

Syntax

@rtrim({text})

Use Case:

Removes only the trailing (right-side) whitespace from a string.

Arguments:

  • {text}: The input text.

Examples:

  1. /echo {@rtrim(end )}

See Also:

@ltrim, @trim

P_stripansi

Syntax

@stripansi({text})

Use Case:

Removes all ANSI escape sequences (color codes) from a string, leaving only plain text.

Arguments:

  • {text}: The text containing ANSI codes.

Examples:

  1. /var {plain} {@stripansi($ansi_data)}

See Also:

@len

P_substr

Syntax

@substr({text}, {start}, {end})

Use Case:

Returns a substring between two specific indices (0-indexed, inclusive).

Arguments:

  • {text} : The string to slice.
  • {start}: Starting index.
  • {end} : Ending index.

Examples:

  1. /echo {@substr(MudBringer, 3, 6)} (Outputs ‘Flin’)

See Also:

@mid

P_trim

Syntax

@trim({text})

Use Case:

Removes all leading and trailing whitespace from a string.

Arguments:

  • {text}: The input text.

Examples:

  1. /var {clean} {@trim( padded )}

See Also:

@ltrim, @rtrim

P_upper

Syntax

@upper({text})

Use Case:

Converts all characters in a string to uppercase.

Arguments:

  • {text}: The input text.

Examples:

  1. /echo {@upper(hello)}

See Also:

@lower