Logo GenPRES

String Module

Trims, splits, compares, replaces and cleans up text. Most functions return an empty string or a default value for a null string.

Functions and values

Function or value Description

String.apply f s

Full Usage: String.apply f s

Parameters:
    f : string -> 'a
    s : string

Returns: 'a
Type parameters: 'a

Apply f to string s

f : string -> 'a
s : string
Returns: 'a

String.arrayConcat cs

Full Usage: String.arrayConcat cs

Parameters:
    cs : char[]

Returns: string

Concatenate an array of chars to a string Example: [|'a'; 'b'; 'c'|] |> arrayConcat yields "abc"

cs : char[]
Returns: string

String.capitalize s

Full Usage: String.capitalize s

Parameters:
    s : string

Returns: string

Make the first character upper and the rest lower of a string

s : string
Returns: string

String.contains

Full Usage: String.contains

Returns: string -> string -> bool

Check if string s2 contains string s1

Returns: string -> string -> bool

String.containsCapsInsens s2 s1

Full Usage: String.containsCapsInsens s2 s1

Parameters:
    s2 : string
    s1 : string

Returns: bool

Check if string s1 contains s2 caps insensitive

s2 : string
s1 : string
Returns: bool

String.countChar c t

Full Usage: String.countChar c t

Parameters:
    c : string
    t : string

Returns: int

Count the number of times character c appears in string t

c : string
t : string
Returns: int

String.countFirstChar c t

Full Usage: String.countFirstChar c t

Parameters:
    c : char
    t : string

Returns: int

Count the number of times that a string t starts with character c

c : char
t : string
Returns: int

String.equals s1 s2

Full Usage: String.equals s1 s2

Parameters:
    s1 : 'a
    s2 : 'a

Returns: bool
Type parameters: 'a (requires equality)

Check if string s1 equals s2

s1 : 'a
s2 : 'a
Returns: bool

String.equalsCapInsens s1 s2

Full Usage: String.equalsCapInsens s1 s2

Parameters:
    s1 : string
    s2 : string

Returns: bool

Check if string s1 equals s2 caps insensitive

s1 : string
s2 : string
Returns: bool

String.firstStringChar

Full Usage: String.firstStringChar

Returns: string -> string

Get the first character of a string as a string

Returns: string -> string

String.firstToUpper

Full Usage: String.firstToUpper

Returns: string -> string

Make the first char of a string upper case

Returns: string -> string

String.get

Full Usage: String.get

Returns: string -> string

Utility to enable type inference

Returns: string -> string

String.isLetter s

Full Usage: String.isLetter s

Parameters:
    s : string

Returns: bool

Check if a string is a letter

s : string
Returns: bool

String.isNullOrEmpty value

Full Usage: String.isNullOrEmpty value

Parameters:
    value : string

Returns: bool

True when s is null or zero-length. White space counts as content here, unlike isNullOrWhiteSpace.

value : string
Returns: bool

String.isNullOrWhiteSpace value

Full Usage: String.isNullOrWhiteSpace value

Parameters:
    value : string

Returns: bool

True when s is null, empty, or only white space.

value : string
Returns: bool

String.length

Full Usage: String.length

Returns: string -> int

Get the length of s

Returns: string -> int

String.letters

Full Usage: String.letters

Returns: string list

Get all letters as a string list

Returns: string list

String.normaliseWhiteSpaceLower s

Full Usage: String.normaliseWhiteSpaceLower s

Parameters:
    s : string

Returns: string

Trim, collapse internal whitespace (tabs/newlines included), lowercase. Tab is the key separator, so it must not survive inside a field.

s : string
Returns: string

String.notEmpty

Full Usage: String.notEmpty

Returns: string -> bool

True when s has content other than white space. The negation of isNullOrWhiteSpace; a null string is not "not empty".

Returns: string -> bool

String.notNullOrEmpty

Full Usage: String.notNullOrEmpty

Returns: string -> bool

True when s has at least one character, white space included.

Returns: string -> bool

String.regex s

Full Usage: String.regex s

Parameters:
    s : string

Returns: Regex

Create a regular expression from a string

s : string
Returns: Regex

String.regexReplace regS replS s

Full Usage: String.regexReplace regS replS s

Parameters:
    regS : string
    replS : string
    s : string

Returns: string

Replace a regular expression in a string Example: regexReplace @"[\d-]" "" "abc123" |> equals "abc"

regS : string
replS : string
s : string
Returns: string

String.remove n s

Full Usage: String.remove n s

Parameters:
    n : int
    s : string

Returns: string
 Removes the last 'n' characters from the input string 's'.
 If the resulting string length is less than 0, an empty string is returned.

 Parameters:
   - n: Number of characters to remove from the end of the string.
   - s: Input string.

 Returns:
   - Modified string with the last 'n' characters removed.
n : int
s : string
Returns: string

String.removeBrackets s

Full Usage: String.removeBrackets s

Parameters:
Returns: string

Remove brackets from a string

s : String
Returns: string

String.removeExtraSpaces input

Full Usage: String.removeExtraSpaces input

Parameters:
    input : string

Returns: string
input : string
Returns: string

String.removeTextBetween start stop text

Full Usage: String.removeTextBetween start stop text

Parameters:
    start : string
    stop : string
    text : string

Returns: string

Removes all characters from a string between start and stop

start : string
stop : string
text : string
Returns: string

String.removeTextBetweenBrackets

Full Usage: String.removeTextBetweenBrackets

Returns: string -> string

Remove all text between brackets

Returns: string -> string

String.removeTrailing chars s

Full Usage: String.removeTrailing chars s

Parameters:
    chars : string seq
    s : String

Returns: string

Remove trailing characters from a string

chars : string seq
s : String
Returns: string

String.removeTrailingZerosFromDutchNumber s

Full Usage: String.removeTrailingZerosFromDutchNumber s

Parameters:
    s : string

Returns: string

Remove trailing zeros from a Dutch number

s : string
Returns: string

String.replace

Full Usage: String.replace

Returns: string -> string -> string -> string

Replace os with ns in string s.

Returns: string -> string -> string -> string

String.replaceNumbers

Full Usage: String.replaceNumbers

Returns: string -> string -> string

Replace all numbers in a string Example: replaceNumbers "123" "a" |> equals "a"

Returns: string -> string -> string

String.restString s

Full Usage: String.restString s

Parameters:
    s : string

Returns: string

Return the rest of a string as a string

s : string
Returns: string

String.sha1Short fields

Full Usage: String.sha1Short fields

Parameters:
    fields : string list

Returns: string

Hash a key field list to a 12-char lowercase hex

fields : string list
Returns: string

String.split dels s

Full Usage: String.split dels s

Parameters:
    dels : string
    s : string

Returns: string list

Split a string s at string dels

dels : string
s : string
Returns: string list

String.splitAt c s

Full Usage: String.splitAt c s

Parameters:
    c : char
    s : string

Returns: string[]

Split string s at character c

c : char
s : string
Returns: string[]

String.startsWith

Full Usage: String.startsWith

Returns: string -> string -> bool

Check whether s1 starts with s2 caps sensitive

Returns: string -> string -> bool

String.startsWithCapsInsensitive

Full Usage: String.startsWithCapsInsensitive

Returns: string -> string -> bool

Check whether s1 starts with s2 caps insensitive

Returns: string -> string -> bool

String.startsWithEqs eqs s2 s1

Full Usage: String.startsWithEqs eqs s2 s1

Parameters:
    eqs : string -> string -> bool
    s2 : string
    s1 : string

Returns: bool

Check whether s1 starts with s2 using string comparison eqs

eqs : string -> string -> bool
s2 : string
s1 : string
Returns: bool

String.subString start length

Full Usage: String.subString start length

Parameters:
    start : int
    length : int

Returns: string -> string

Get a substring starting at start with length length

start : int
length : int
Returns: string -> string

String.toLower

Full Usage: String.toLower

Returns: string -> string

Make string all lower chars

Returns: string -> string

String.toString o

Full Usage: String.toString o

Parameters:
    o : 'a

Returns: string
Type parameters: 'a

Convert object to string

o : 'a
Returns: string

String.toUpper

Full Usage: String.toUpper

Returns: string -> string

Make string all upper chars

Returns: string -> string

String.trim

Full Usage: String.trim

Returns: string -> string

Trim string s

Returns: string -> string

Type something to start searching.