Header menu logo Str

ExtensionsString Module

Extension methods for System.String. Adds extension members on System.String. E.G. .First, .Second, .Last and similar indices. Also adds functionality for negative indices and s.Slice(startIdx:int , endIdx: int) that works with negative numbers. This module is NOT automatically opened when the namespace Str is opened.

Types

Type Description

StrException

An Exception for the string functions defined in Str

Functions and values

Function or value Description

exnf s

Full Usage: exnf s

Parameters:
    s : string

Returns: string

For string formatting in exceptions. Including surrounding quotes

s : string
Returns: string

Type extensions

Type extension Description

this.First

Full Usage: this.First

Parameters:
    () : unit

Returns: char
Modifiers: inline

Returns then first character of the string fails if string is empty

Extended Type: String

() : unit
Returns: char

this.First

Full Usage: this.First

Returns: char
Modifiers: inline

Returns then first character of the string fails if string is empty

Extended Type: String

Returns: char

this.Get

Full Usage: this.Get

Parameters:
    index : int

Returns: char
Modifiers: inline

Gets an character at index, same as this.[index] or this.Idx(index) Throws a descriptive Exception if the index is out of range. (Use this.GetNeg(i) member if you want to use negative indices too)

Extended Type: String

index : int
Returns: char

this.GetLooped

Full Usage: this.GetLooped

Parameters:
    index : int

Returns: char

Any index will return a value. Rarr is treated as an endless loop in positive and negative direction

Extended Type: String

index : int
Returns: char

this.GetNeg

Full Usage: this.GetNeg

Parameters:
    index : int

Returns: char

Gets an item in the string by index. Allows for negative index too ( -1 is last item, like Python) (from the release of F# 5 on a negative index can also be done with '^' prefix. E.g. ^0 for the last item)

Extended Type: String

index : int
Returns: char

this.Idx

Full Usage: this.Idx

Parameters:
    index : int

Returns: char
Modifiers: inline

Gets an character at index, same as this.[index] or this.Get(index) Throws a descriptive Exception if the index is out of range. (Use this.GetNeg(i) member if you want to use negative indices too)

Extended Type: String

index : int
Returns: char

this.Last

Full Usage: this.Last

Parameters:
    () : unit

Returns: char
Modifiers: inline

Returns the last character of the string fails if string is empty

Extended Type: String

() : unit
Returns: char

this.Last

Full Usage: this.Last

Returns: char
Modifiers: inline

Returns the last character of the string fails if string is empty

Extended Type: String

Returns: char

this.LastIndex

Full Usage: this.LastIndex

Parameters:
    () : unit

Returns: int
Modifiers: inline

Returns the last valid index in the string same as: s.Length - 1

Extended Type: String

() : unit
Returns: int

this.LastIndex

Full Usage: this.LastIndex

Returns: int
Modifiers: inline

Returns the last valid index in the string same as: s.Length - 1

Extended Type: String

Returns: int

this.LastX

Full Usage: this.LastX

Parameters:
    x : int

Returns: string
Modifiers: inline

Returns the last x(int) characters of the string same as string.LastN

Extended Type: String

x : int
Returns: string

this.ReplaceFirst

Full Usage: this.ReplaceFirst

Parameters:
    oldValue : string
    newValue : string

Returns: String

Returns a new string in which only the first occurrences of a specified string in the current instance is replaced with another specified string. (Will return the same instance if text to replace is not found)

Extended Type: String

oldValue : string
newValue : string
Returns: String

this.ReplaceLast

Full Usage: this.ReplaceLast

Parameters:
    oldValue : string
    newValue : string

Returns: String

Returns a new string in which only the last occurrences of a specified string in the current instance is replaced with another specified string. (Will return the same instance if text to replace is not found)

Extended Type: String

oldValue : string
newValue : string
Returns: String

this.Second

Full Usage: this.Second

Parameters:
    () : unit

Returns: char
Modifiers: inline

Returns the second character of the string fails if string has less than two characters

Extended Type: String

() : unit
Returns: char

this.Second

Full Usage: this.Second

Returns: char
Modifiers: inline

Returns the second character of the string fails if string has less than two characters

Extended Type: String

Returns: char

this.SecondLast

Full Usage: this.SecondLast

Parameters:
    () : unit

Returns: char
Modifiers: inline

Returns the second last character of the string fails if string has less than two characters

Extended Type: String

() : unit
Returns: char

this.SecondLast

Full Usage: this.SecondLast

Returns: char
Modifiers: inline

Returns the second last character of the string fails if string has less than two characters

Extended Type: String

Returns: char

this.Slice

Full Usage: this.Slice

Parameters:
    startIdx : int
    endIdx : int

Returns: string

Allows for negative indices too. -1 is last character Includes end index in string for example str.Slice(0,-3) will trim off the last two character from the string

Extended Type: String

startIdx : int
endIdx : int
Returns: string

this.Third

Full Usage: this.Third

Parameters:
    () : unit

Returns: char
Modifiers: inline

Returns the third character of the string fails if string has less than three characters

Extended Type: String

() : unit
Returns: char

this.Third

Full Usage: this.Third

Returns: char
Modifiers: inline

Returns the third character of the string fails if string has less than three characters

Extended Type: String

Returns: char

this.ThirdLast

Full Usage: this.ThirdLast

Parameters:
    () : unit

Returns: char
Modifiers: inline

Returns the third last character of the string fails if string has less than three characters

Extended Type: String

() : unit
Returns: char

this.ThirdLast

Full Usage: this.ThirdLast

Returns: char
Modifiers: inline

Returns the third last character of the string fails if string has less than three characters

Extended Type: String

Returns: char

Type something to start searching.