juno.base.string Module

Contains methods for working with strings.

Methods that perform comparisons are culturally sensitive.

Licence
See licence.txt for use and distribution terms.

int compare(char[] stringA, char[] stringB, bool ignoreCase, Culture culture = cast(Culture)null);
int compare(char[] stringA, char[] stringB, Culture culture);
int compare(char[] stringA, char[] stringB);

Compares two specified strings, ignoring or honouring their case.

Parameters
char[] stringA
The first string.
char[] stringB
The second string.
bool ignoreCase
A value indicating a case- sensitive or insensitive comparison.

Returns
An integer indicating the lexical relationship between the two strings (less than zero if stringA is less then stringB; zero if stringA equals stringB; greater than zero if stringA is greater than stringB).

int compare(char[] stringA, int indexA, char[] stringB, int indexB, int length, bool ignoreCase = false, Culture culture = cast(Culture)null);
int compare(char[] stringA, int indexA, char[] stringB, int indexB, int length, Culture culture);

Compares two specified strings, ignoring or honouring their case.

Parameters
char[] stringA
The first string.
int indexA
The position of the substring withing stringA.
char[] stringB
The second string.
int indexB
The position of the substring withing stringB.
bool ignoreCase
A value indicating a case- sensitive or insensitive comparison.

Returns
An integer indicating the lexical relationship between the two strings (less than zero if the substring in stringA is less then the substring in stringB; zero if the substrings are equal; greater than zero if the substring in stringA is greater than the substring in stringB).

bool equals(char[] stringA, char[] stringB, bool ignoreCase = false);

Determines whether two specified strings are the same, ignoring or honouring their case.

Parameters
char[] stringA
The first string.
char[] stringB
The second string.
bool ignoreCase
A value indicating a case- sensitive or insensitive comparison.

Returns
true if stringA is the same as stringB; otherwise, false.

bool contains(char[] s, char[] value);

Determines whether the value parameter occurs within the s parameter.

Parameters
char[] s
The string to search within.
char[] value
The string to find.

Returns
true if the value parameter occurs within the s parameter; otherwise, false.

int indexOf(char[] s, char value, int index = 0, int count = -1);

Retrieves the index of the first occurrence of the specified character within the specified string.

Parameters
char[] s
The string to search within.
char value
The character to find.
int index
The start position of the search.
int count
The number of characters to examine.

Returns
The index of value if that character is found, or -1 if it is not.

int indexOf(char[] s, char[] value, int index, int count, bool ignoreCase = false, Culture culture = cast(Culture)null);
int indexOf(char[] s, char[] value, int index, bool ignoreCase = false, Culture culture = cast(Culture)null);
int indexOf(char[] s, char[] value, bool ignoreCase = false, Culture culture = cast(Culture)null);

Retrieves the index of the first occurrence of the specified value in the specified string s.

Parameters
char[] s
The string to search within.
char[] value
The string to find.
int index
The start position of the search.
int count
The number of characters to examine.
bool ignoreCase
A value indicating a case- sensitive or insensitive comparison.

Returns
The index of value if that string is found, or -1 if it is not.

int lastIndexOf(char[] s, char value, int index = 0, int count = -1);

Retrieves the index of the last occurrence of the specified character within the specified string.

Parameters
char[] s
The string to search within.
char value
The character to find.
int index
The start position of the search.
int count
The number of characters to examine.

Returns
The index of value if that character is found, or -1 if it is not.

int lastIndexOf(char[] s, char[] value, int index, int count, bool ignoreCase = false, Culture culture = cast(Culture)null);
int lastIndexOf(char[] s, char[] value, int index, bool ignoreCase = false, Culture culture = cast(Culture)null);
int lastIndexOf(char[] s, char[] value, bool ignoreCase = false, Culture culture = cast(Culture)null);

Retrieves the index of the last occurrence of value within the specified string s.

Parameters
char[] s
The string to search within.
char[] value
The string to find.
int index
The start position of the search.
int count
The number of characters to examine.
bool ignoreCase
A value indicating a case- sensitive or insensitive comparison.

Returns
The index of value if that character is found, or -1 if it is not.

bool startsWith(char[] s, char[] value, bool ignoreCase = false, Culture culture = cast(Culture)null);

Determines whether the beginning of s matches value.

Parameters
char[] s
The string to search.
char[] value
The string to compare.
bool ignoreCase
A value indicating a case- sensitive or insensitive comparison.

Returns
true if value matches the beginning of s; otherwise, false.

bool endsWith(char[] s, char[] value, bool ignoreCase = false, Culture culture = cast(Culture)null);

Determines whether the end of s matches value.

Parameters
char[] s
The string to search.
char[] value
The string to compare.
bool ignoreCase
A value indicating a case- sensitive or insensitive comparison.

Returns
true if value matches the end of s; otherwise, false.

char[] insert(char[] s, int index, char[] value);

Inserts value at the specified index in s.

Parameters
char[] s
The string in which to insert value.
int index
The position of the insertion.
char[] value
The string to insert.

Returns
A new string with value inserted at index.

char[] remove(char[] s, int index, int count);
char[] remove(char[] s, int index);

Deletes characters from s beginning at the specified position.

Parameters
char[] s
The string from which to delete characters.
int index
The position to begin deleting characters.
int count
The number of characters to delete.

Returns
A new string equivalent to s less count number of characters.

bool isWhitespace(char c);

Indicates whether the specified character is white space.

Parameters
char c
A character.

Returns
true if c is white space; otherwise, false.

char[][] split(char[] s, char[] separator, int count, bool removeEmptyEntries = false);
char[][] split(char[] s, char[] separator, bool removeEmptyEntries);
char[][] split(char[] s, char[] separator...);

Returns a string array containing the substrings in s that are delimited by elements of the specified char array.

Parameters
char[] s
The string to split.
char[] separator
An array of characters that delimit the substrings in s.
int count
The maximum number of substrings to return.
bool removeEmptyEntries
true to omit empty array elements from the array returned, or false to include empty array elements in the array returned.

Returns
An array whose elements contain the substrings in s that are delimited by one or more characters in separator.

char[][] split(char[] s, char[][] separator, int count = 2147483647, bool removeEmptyEntries = false);
char[][] split(char[] s, char[][] separator, bool removeEmptyEntries);

Returns a string array containing the substrings in s that are delimited by elements of the specified string array.

Parameters
char[] s
The string to split.
char[][] separator
An array of strings that delimit the substrings in s.
int count
The maximum number of substrings to return.
bool removeEmptyEntries
true to omit empty array elements from the array returned, or false to include empty array elements in the array returned.

Returns
An array whose elements contain the substrings in s that are delimited by one or more strings in separator.

char[] join(char[] separator, char[][] value, int index = 0, int count = -1);

Concatenates separator between each element of value, returning a single concatenated string.

Parameters
char[] separator
A string.
char[][] value
An array of strings.
int index
The first element in value to use.
int count
The number of elements of value to use.

Returns
A string containing the strings in value joined by separator.

char[] replace(char[] s, char oldChar, char newChar);

Replaces all instances of oldChar with newChar in s.

Parameters
char[] s
A string containing oldChar.
char oldChar
The character to be replaced.
char newChar
The character to replace all instances of oldChar.

Returns
A string equivalent to s but with all instances of oldChar replaced with newChar.

char[] replace(char[] s, char[] oldValue, char[] newValue);

Replaces all instances of oldValue with newValue in s.

Parameters
char[] s
A string containing oldValue.
char[] oldValue
The string to be replaced.
char[] newValue
The string to replace all instances of oldValue.

Returns
A string equivalent to s but with all instances of oldValue replaced with newValue.

char[] padLeft(char[] s, int totalWidth, char paddingChar = ' ');

Right-aligns the characters in s, padding on the left with paddingChar for a specified total length.

Parameters
char[] s
The string to pad.
int totalWidth
The number of characters in the resulting string.
char paddingChar
A padding character.

Returns
A string equivalent to s but right-aligned and padded on the left with paddingChar.

char[] padRight(char[] s, int totalWidth, char paddingChar = ' ');

Left-aligns the characters in s, padding on the right with paddingChar for a specified total length.

Parameters
char[] s
The string to pad.
int totalWidth
The number of characters in the resulting string.
char paddingChar
A padding character.

Returns
A string equivalent to s but left-aligned and padded on the right with paddingChar.

char[] trim(char[] s, char[] trimChars...);

Removes all leading and trailing occurrences of a set of characters specified in trimChars from s.

Returns
The string that remains after all occurrences of the characters in trimChars are removed from the start and end of s.

char[] trimStart(char[] s, char[] trimChars...);

Removes all leading occurrences of a set of characters specified in trimChars from s.

Returns
The string that remains after all occurrences of the characters in trimChars are removed from the start of s.

char[] trimEnd(char[] s, char[] trimChars...);

Removes all trailing occurrences of a set of characters specified in trimChars from s.

Returns
The string that remains after all occurrences of the characters in trimChars are removed from the end of s.

char[] substring(char[] s, int index, int length);
char[] substring(char[] s, int index);

Retrieves a substring from s starting at the specified character position and has a specified length.

Parameters
char[] s
A string.
int index
The starting character position of a substring in s.
int length
The number of characters in the substring.

Returns
The substring of length that begins at index in s.

char[] toLower(char[] s, Culture culture = cast(Culture)null);

Returns a copy of s converted to lowercase.

Parameters
char[] s
The string to convert.

Returns
a string in lowercase.

char[] toUpper(char[] s, Culture culture = cast(Culture)null);

Returns a copy of s converted to uppercase.

Parameters
char[] s
The string to convert.

Returns
a string in uppercase.

char[] format(IFormatProvider provider, char[] format,...);
char[] format(char[] format,...);

Replaces the format items in the specified string with string representations of the corresponding items in the specified argument list.

Parameters
IFormatProvider provider
An object supplying culture-specific formatting information.
char[] format
A format string.
_argptr
An argument list containing zero or more items to format.

Returns
A copy of format in which the format items have been replaced by string representations of the corresponding items in the argument list.