Note: This API documentation is for FAKE version 4. The migration API documentation can be found here. The API documentation for the new fake 5 modules can be found here

StringHelper

Contains basic functions for string manipulation.

Functions and values

Function or valueDescription
( <* ) prefix text
Signature: prefix:string -> text:string -> bool

Checks whether the given text starts with the given prefix

( >** ) pattern text
Signature: pattern:string -> text:string -> bool

Determines if a text matches a given regex pattern.

( >=> ) pattern replacement text
Signature: pattern:string -> replacement:string -> text:string -> string

Find a regex pattern in a text and replaces it with the given replacement.

append text builder
Signature: text:string -> builder:StringBuilder -> StringBuilder

Appends a text to a StringBuilder.

appendFileNamesIfNotNull(...)
Signature: fileNames:seq<string> -> builder:StringBuilder -> StringBuilder

Appends all notnull fileNames.

appendIfFalse(p)
Signature: p:bool -> string -> StringBuilder -> StringBuilder

Appends a text if the predicate is false.

appendIfNotNull value s
Signature: value:Object -> s:string -> StringBuilder -> StringBuilder

Appends a text if the value is not null.

appendIfNotNullOrEmpty value s
Signature: value:string -> s:string -> StringBuilder -> StringBuilder

Appends a text if the value is not null or empty.

appendIfSome o f builder
Signature: o:'a option -> f:('a -> string) -> builder:StringBuilder -> StringBuilder
Type parameters: 'a

Appends string of function value if option has some value

appendIfTrue p s builder
Signature: p:bool -> s:string -> builder:StringBuilder -> StringBuilder

Appends a text if the predicate is true.

appendIfTrueWithoutQuotes p s builder
Signature: p:bool -> s:string -> builder:StringBuilder -> StringBuilder
appendQuotedIfNotNull value s builder
Signature: value:Object -> s:string -> builder:StringBuilder -> StringBuilder

Appends a quoted text if the value is not null.

appendStringIfValueIsNotNull(value)
Signature: value:'?13670 -> string -> StringBuilder -> StringBuilder
Type parameters: '?13670

Appends a text if the value is not null.

appendStringIfValueIsNotNullOrEmpty(...)
Signature: value:string -> string -> StringBuilder -> StringBuilder

Appends a text if the value is not null or empty.

AppendToFile file lines
Signature: file:string -> lines:seq<string> -> unit

Appends all lines to a file line by line

appendWithoutQuotes text builder
Signature: text:string -> builder:StringBuilder -> StringBuilder

Appends a text to a StringBuilder without surrounding quotes.

appendWithoutQuotesIfNotNull value s
Signature: value:Object -> s:string -> StringBuilder -> StringBuilder

Appends a text without quoting if the value is not null.

charsAndDigits
Signature: char list

Returns all standard chars and digits.

Colon
Signature: char
ConvertFileToWindowsLineBreaks(fileName)
Signature: fileName:string -> unit

Reads a file line by line and replaces all line breaks to windows line breaks - uses a temp file to store the contents in order to prevent OutOfMemory exceptions

ConvertTextToWindowsLineBreaks(text)
Signature: text:string -> string

Converts all line breaks in a text to windows line breaks

DecodeBase64Utf8String(text)
Signature: text:string -> string

Decodes a Base64-encoded UTF-8-encoded string

EncapsulateApostrophe(text)
Signature: text:string -> string

Encapsulates the Apostrophe

endsWith suffix text
Signature: suffix:string -> text:string -> bool

Checks whether the given text ends with the given suffix

endsWithSlash
Signature: string -> bool

Determines whether the last character of the given matches Path.DirectorySeparatorChar.

isLetterOrDigit(c)
Signature: c:char -> bool

Checks whether the given char is a standard char or digit.

isNotNullOrEmpty(value)
Signature: value:string -> bool

Returns if the string is not null or empty

isNullOrEmpty(value)
Signature: value:string -> bool

Returns if the string is null or empty

isNullOrWhiteSpace(value)
Signature: value:string -> bool

Returns if the string is null or empty or completely whitespace

isUmlaut(c)
Signature: c:char -> bool

Checks whether the given char is a german umlaut.

liftString(x)
Signature: x:string -> string option

Lifts a string to an option

LinuxLineBreaks
Signature: string

Represents Linux line breaks

MacLineBreaks
Signature: string

Represents Mac line breaks

NormalizeVersion(version)
Signature: version:string -> string

Removes all trailing .0 from a version string

ProduceRelativePath(...)
Signature: baseLocation:string -> targetLocation:string -> string

Produces relative path when possible to go from baseLocation to targetLocation.

ReadFile(file)
Signature: file:string -> seq<string>

Reads a file line by line

ReadFileAsBytes(file)
Signature: file:string -> byte []

Reads a file as one array of bytes

ReadFileAsString(file)
Signature: file:string -> string

Reads a file as one text

ReadLine(file)
Signature: file:string -> string

Reads the first line of a file. This can be helpful to read a password from file.

RemoveLineBreaks(text)
Signature: text:string -> string

Removes linebreaks from the given string

replace pattern replacement text
Signature: pattern:string -> replacement:string -> text:string -> string

Replaces the given pattern in the given text with the replacement

ReplaceFile fileName text
Signature: fileName:string -> text:string -> unit

Replaces the file with the given string

replaceFirst pattern replacement text
Signature: pattern:string -> replacement:string -> text:string -> string

Replaces the first occurrence of the pattern with the given replacement.

ReplaceInFile replaceF fileName
Signature: replaceF:(string -> string) -> fileName:string -> unit

Replaces the text in the given file

separated delimiter items
Signature: delimiter:string -> items:seq<string> -> string

Converts a sequence of strings to a string with delimiters

shortenCurrentDirectory(value)
Signature: value:string -> string

Replaces any occurence of the currentDirectory with .

split delimiter text
Signature: delimiter:char -> text:string -> string list

Splits the given string at the given char delimiter

splitRemove delimiter text
Signature: delimiter:char -> text:string -> string list
splitStr delimiterStr text
Signature: delimiterStr:string -> text:string -> string list

Splits the given string at the given string delimiter

startsWith prefix text
Signature: prefix:string -> text:string -> bool

Checks whether the given text starts with the given prefix

toLines(text)
Signature: text:seq<string> -> string

Converts a sequence of strings into a string separated with line ends

toLower(s)
Signature: s:string -> string

Converts all characters in a string to lower case.

toRelativePath(value)
Signature: value:string -> string

Replaces the absolute path to a relative path.

toText(builder)
Signature: builder:StringBuilder -> string

Returns the text from the StringBuilder

trim(x)
Signature: x:string -> string

Trims the given string

trimChars chars x
Signature: chars:char [] -> x:string -> string

Trims the given string

trimEndChars chars x
Signature: chars:char [] -> x:string -> string

Trims the end of the given string

trimSeparator(s)
Signature: s:string -> string

Trims the given string with the DirectorySeparatorChar

trimSlash(s)
Signature: s:string -> string

Removes the slashes from the end of the given string

trimSpecialChars(text)
Signature: text:string -> string

Trims all special characters from a string.

trimStartChars chars x
Signature: chars:char [] -> x:string -> string

Trims the start of the given string

WindowsLineBreaks
Signature: string

Represents Windows line breaks

WriteBytesToFile file bytes
Signature: file:string -> bytes:byte [] -> unit

Writes a byte array to a file

WriteFile file lines
Signature: file:string -> lines:seq<string> -> unit

Writes a file line by line

WriteStringToFile append fileName text
Signature: append:bool -> fileName:string -> text:string -> unit

Writes a string to a file

WriteToFile append fileName lines
Signature: append:bool -> fileName:string -> lines:seq<string> -> unit

Writes a file line by line