FSharpPlus


String Module

Additional operations on String

Functions and values

Function or value Description

String.contains char source

Full Usage: String.contains char source

Parameters:
    char : char
    source : string

Returns: bool

Does the source string contain the given character? Use `String.isSubstring` to check for strings.

char : char
source : string
Returns: bool

String.drop count source

Full Usage: String.drop count source

Parameters:
    count : int
    source : string

Returns: string

Returns a string that drops first N characters of the original string. When count exceeds the length of the string it returns an empty string.

count : int
source : string
Returns: string

String.endsWith subString source

Full Usage: String.endsWith subString source

Parameters:
    subString : string
    source : string

Returns: bool

Does the source string end with the given subString? -- function wrapper for String.EndsWith method using InvariantCulture.

subString : string
source : string
Returns: bool

String.findIndex predicate source

Full Usage: String.findIndex predicate source

Parameters:
    predicate : char -> bool
    source : string

Returns: int

Finds the first index of the char in the substring which satisfies the given predicate. Note: throws an ArgumentException when not found.

predicate : char -> bool
source : string
Returns: int

String.findSliceIndex slice source

Full Usage: String.findSliceIndex slice source

Parameters:
    slice : string
    source : string

Returns: int The index of the slice.

Returns the index of the first occurrence of the specified slice in the source.

slice : string
source : string
Returns: int

The index of the slice.

ArgumentException Thrown when the slice was not found in the sequence.

String.getBytes encoding source

Full Usage: String.getBytes encoding source

Parameters:
Returns: byte[]

Converts a string to a byte-array using the specified encoding.

encoding : Encoding
source : string
Returns: byte[]

String.intercalate separator source

Full Usage: String.intercalate separator source

Parameters:
    separator : string
    source : seq<string>

Returns: string

Concatenates all elements, using the specified separator between each element.

separator : string
source : seq<string>
Returns: string

String.intersperse element source

Full Usage: String.intersperse element source

Parameters:
    element : char
    source : string

Returns: string

Inserts a separator char between each char in the source string.

element : char
source : string
Returns: string

String.isSubString subString source

Full Usage: String.isSubString subString source

Parameters:
    subString : string
    source : string

Returns: bool

Does the source string contain the given subString? -- function wrapper for String.Contains method.

subString : string
source : string
Returns: bool

String.item index source

Full Usage: String.item index source

Parameters:
    index : int
    source : string

Returns: char

(Unsafely) Returns the char at the given index in the source string. This is a function wrapper for `source.[index]` method. Note: this is not exception safe, and will throw System.IndexOutOfRangeException when the given index is out of bounds.

index : int
source : string
Returns: char

String.normalize normalizationForm source

Full Usage: String.normalize normalizationForm source

Parameters:
Returns: string

Returns a new string whose textual value is the same as this string, but whose binary representation is in the specified Unicode normalization form. This is a null safe function wrapper of the String.Normalize method.

normalizationForm : NormalizationForm
source : string
Returns: string

String.ofArray source

Full Usage: String.ofArray source

Parameters:
    source : char[]

Returns: String

Converts an array of chars to a String.

source : char[]
Returns: String

String.ofCodePoints source

Full Usage: String.ofCodePoints source

Parameters:
    source : seq<int>

Returns: string

Converts the array of Int32 code-points (the actual Unicode Code Point number) to a string.

source : seq<int>
Returns: string

String.ofList source

Full Usage: String.ofList source

Parameters:
    source : char list

Returns: String

Converts a list of chars to a String.

source : char list
Returns: String

String.ofSeq source

Full Usage: String.ofSeq source

Parameters:
    source : seq<char>

Returns: string

Converts a seq of chars to a String.

source : seq<char>
Returns: string

String.padLeft totalLength source

Full Usage: String.padLeft totalLength source

Parameters:
    totalLength : int
    source : string

Returns: string

Pads the beginning of the given string with spaces so that it has a specified total length.

totalLength : int
source : string
Returns: string

String.padLeftWith totalLength paddingChar source

Full Usage: String.padLeftWith totalLength paddingChar source

Parameters:
    totalLength : int
    paddingChar : char
    source : string

Returns: string

Pads the beginning of the given string with a specified character so that it has a specified total length.

totalLength : int
paddingChar : char
source : string
Returns: string

String.padRight totalLength source

Full Usage: String.padRight totalLength source

Parameters:
    totalLength : int
    source : string

Returns: string

Pads the end of the given string with spaces so that it has a specified total length.

totalLength : int
source : string
Returns: string

String.padRightWith totalLength paddingChar source

Full Usage: String.padRightWith totalLength paddingChar source

Parameters:
    totalLength : int
    paddingChar : char
    source : string

Returns: string

Pads the end of the given string with a specified character so that it has a specified total length.

totalLength : int
paddingChar : char
source : string
Returns: string

String.removeDiacritics source

Full Usage: String.removeDiacritics source

Parameters:
    source : string

Returns: string

Removes diacritics (accents) from the given source string. The approach uses `normalize` to split the input string into constituent glyphs (basically separating the "base" characters from the diacritics) and then scans the result and retains only the base characters.

source : string
Returns: string

String.replace oldValue newValue source

Full Usage: String.replace oldValue newValue source

Parameters:
    oldValue : string
    newValue : string
    source : string

Returns: string

Replaces a substring with the given replacement string.

oldValue : string
newValue : string
source : string
Returns: string

String.rev source

Full Usage: String.rev source

Parameters:
    source : string

Returns: String

Reverses the given string.

source : string
Returns: String

String.skip count source

Full Usage: String.skip count source

Parameters:
    count : int
    source : string

Returns: string

(Unsafely) Skips over the first count chars in the string. Use `String.drop` for a safe version. Note: will throw System.ArgumentOutOfRangeException if you try to skip more than the number of chars in the string.

count : int
source : string
Returns: string

String.skipWhile predicate source

Full Usage: String.skipWhile predicate source

Parameters:
    predicate : char -> bool
    source : string

Returns: string

Skips over chars from the source string while the given predicate is true.

predicate : char -> bool
source : string
Returns: string

String.split separators source

Full Usage: String.split separators source

Parameters:
    separators : seq<string>
    source : string

Returns: seq<string>

Creates a sequence of strings by splitting the source string on any of the given separators.

separators : seq<string>
source : string
Returns: seq<string>

String.startsWith subString source

Full Usage: String.startsWith subString source

Parameters:
    subString : string
    source : string

Returns: bool

Does the source string start with the given subString? -- function wrapper for String.StartsWith method using InvariantCulture.

subString : string
source : string
Returns: bool

String.take count source

Full Usage: String.take count source

Parameters:
    count : int
    source : string

Returns: string

(Unsafely) Takes the first count chars in the string. Use `String.truncate` for a safe version. Note: will throw System.ArgumentOutOfRangeException if you try to take more than the number of chars in the string.

count : int
source : string
Returns: string

String.takeWhile predicate source

Full Usage: String.takeWhile predicate source

Parameters:
    predicate : char -> bool
    source : string

Returns: string

Takes chars from the source string while the given predicate is true.

predicate : char -> bool
source : string
Returns: string

String.toArray source

Full Usage: String.toArray source

Parameters:
    source : string

Returns: char[]

Converts the given string to an array of chars.

source : string
Returns: char[]

String.toCodePoints source

Full Usage: String.toCodePoints source

Parameters:
    source : string

Returns: seq<int>

Converts the given string to an array of Int32 code-points (the actual Unicode Code Point number).

source : string
Returns: seq<int>

String.toList source

Full Usage: String.toList source

Parameters:
    source : string

Returns: char list

Converts the given string to a list of chars.

source : string
Returns: char list

String.toLower source

Full Usage: String.toLower source

Parameters:
    source : string

Returns: string

Converts to lowercase -- nullsafe function wrapper for String.ToLowerInvariant method.

source : string
Returns: string

String.toSeq source

Full Usage: String.toSeq source

Parameters:
    source : string

Returns: seq<char>

Converts the given string to a seq of chars.

source : string
Returns: seq<char>

String.toUpper source

Full Usage: String.toUpper source

Parameters:
    source : string

Returns: string

Converts to uppercase -- nullsafe function wrapper for String.ToUpperInvariant method.

source : string
Returns: string

String.trim trimChars source

Full Usage: String.trim trimChars source

Parameters:
    trimChars : seq<char>
    source : string

Returns: string

Removes all leading and trailing occurrences of specified characters from the given string.

trimChars : seq<char>
source : string
Returns: string

String.trimEnd trimChars source

Full Usage: String.trimEnd trimChars source

Parameters:
    trimChars : seq<char>
    source : string

Returns: string

Removes all trailing occurrences of specified characters from the given string.

trimChars : seq<char>
source : string
Returns: string

String.trimEndWhiteSpaces source

Full Usage: String.trimEndWhiteSpaces source

Parameters:
    source : string

Returns: string

Trims trailing white spaces -- function wrapper for String.TrimEnd method. Note this is distinct from trim which trims the given characters, not white spaces.

source : string
Returns: string

String.trimStart trimChars source

Full Usage: String.trimStart trimChars source

Parameters:
    trimChars : seq<char>
    source : string

Returns: string

Removes all leading occurrences of specified characters from the given string.

trimChars : seq<char>
source : string
Returns: string

String.trimStartWhiteSpaces source

Full Usage: String.trimStartWhiteSpaces source

Parameters:
    source : string

Returns: string

Trims leading white spaces -- function wrapper for String.TrimStart method. Note this is distinct from trim which trims the given characters, not white spaces.

source : string
Returns: string

String.trimWhiteSpaces source

Full Usage: String.trimWhiteSpaces source

Parameters:
    source : string

Returns: string

Trims leading and trailing white spaces -- function wrapper for String.Trim method. Note this is distinct from trim which trims the given characters, not white spaces.

source : string
Returns: string

String.truncate count source

Full Usage: String.truncate count source

Parameters:
    count : int
    source : string

Returns: string

Returns a string that has at most N characters from the beginning of the original string. It returns the original string if it is shorter than count.

count : int
source : string
Returns: string

String.tryFindIndex predicate source

Full Usage: String.tryFindIndex predicate source

Parameters:
    predicate : char -> bool
    source : string

Returns: int option

Tries to find the first index of the char in the substring which satisfies the given predicate.

predicate : char -> bool
source : string
Returns: int option

String.tryFindSliceIndex slice source

Full Usage: String.tryFindSliceIndex slice source

Parameters:
    slice : string
    source : string

Returns: int option The index of the slice or None.

Returns the index of the first occurrence of the specified slice in the source. Returns None if not found.

slice : string
source : string
Returns: int option

The index of the slice or None.

String.tryHead source

Full Usage: String.tryHead source

Parameters:
    source : string

Returns: char option

Gets the first char of the string, or None if the string is empty.

source : string
Returns: char option

String.tryItem index source

Full Usage: String.tryItem index source

Parameters:
    index : int
    source : string

Returns: char option

Returns the char (as an Option) at the given index in the source string, returning `None` if out of bounds.

index : int
source : string
Returns: char option

String.tryLast source

Full Usage: String.tryLast source

Parameters:
    source : string

Returns: char option

Gets the last char of the string, or None if the string is empty.

source : string
Returns: char option