Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • StringUtils

Index

Properties

Static FORMAT_ALL_LOWER_CASE

FORMAT_ALL_LOWER_CASE: "FORMAT_ALL_LOWER_CASE" = "FORMAT_ALL_LOWER_CASE"

Static FORMAT_ALL_UPPER_CASE

FORMAT_ALL_UPPER_CASE: "FORMAT_ALL_UPPER_CASE" = "FORMAT_ALL_UPPER_CASE"

Static FORMAT_CAMEL_CASE

FORMAT_CAMEL_CASE: "FORMAT_CAMEL_CASE" = "FORMAT_CAMEL_CASE"

Static FORMAT_FIRST_UPPER_REST_LOWER

FORMAT_FIRST_UPPER_REST_LOWER: "FORMAT_FIRST_UPPER_REST_LOWER" = "FORMAT_FIRST_UPPER_REST_LOWER"

Static FORMAT_LOWER_CAMEL_CASE

FORMAT_LOWER_CAMEL_CASE: "FORMAT_LOWER_CAMEL_CASE" = "FORMAT_LOWER_CAMEL_CASE"

Static FORMAT_LOWER_SNAKE_CASE

FORMAT_LOWER_SNAKE_CASE: "FORMAT_LOWER_SNAKE_CASE" = "FORMAT_LOWER_SNAKE_CASE"

Static FORMAT_SENTENCE_CASE

FORMAT_SENTENCE_CASE: "FORMAT_SENTENCE_CASE" = "FORMAT_SENTENCE_CASE"

Static FORMAT_SNAKE_CASE

FORMAT_SNAKE_CASE: "FORMAT_SNAKE_CASE" = "FORMAT_SNAKE_CASE"

Static FORMAT_START_CASE

FORMAT_START_CASE: "FORMAT_START_CASE" = "FORMAT_START_CASE"

Static FORMAT_UPPER_CAMEL_CASE

FORMAT_UPPER_CAMEL_CASE: "FORMAT_UPPER_CAMEL_CASE" = "FORMAT_UPPER_CAMEL_CASE"

Static FORMAT_UPPER_SNAKE_CASE

FORMAT_UPPER_SNAKE_CASE: "FORMAT_UPPER_SNAKE_CASE" = "FORMAT_UPPER_SNAKE_CASE"

Methods

Static compareByLevenshtein

  • compareByLevenshtein(string1: string, string2: string): number
  • Parameters

    • string1: string
    • string2: string

    Returns number

    The number of characters to replace to convert $string1 into $string2 where 0 means both strings are the same. The higher the result, the more different the strings are.

Static compareSimilarityPercent

  • compareSimilarityPercent(string1: string, string2: string): number
  • Parameters

    • string1: string
    • string2: string

    Returns number

    A number between 0 and 100, being 100 if both strings are the same and 0 if both strings are totally different

Static countByCase

  • countByCase(string: string, letterCase?: string): number
  • Parameters

    • string: string
    • Default value letterCase: string = StringUtils.FORMAT_ALL_UPPER_CASE

    Returns number

    The number of characters with the specified letter case that are present on the string

Static countPathElements

  • countPathElements(path: string): number
  • Parameters

    • path: string

    Returns number

    The number of elements that are listed on the provided path

Static countStringOccurences

  • countStringOccurences(string: string, findMe: string): number
  • Parameters

    • string: string
    • findMe: string

    Returns number

    The number of times that findMe appears on string

Static countWords

  • countWords(string: string, wordSeparator?: string): number
  • Parameters

    • string: string
    • Default value wordSeparator: string = " "

    Returns number

    The number of words (elements divided by the wordSeparator value) that are present on the string

Static findMostSimilarString

  • findMostSimilarString(): void
  • Returns void

Static findMostSimilarStringIndex

  • findMostSimilarStringIndex(): void
  • Returns void

Static forceNonEmptyString

  • forceNonEmptyString(value: any, valueName?: string, errorMessage?: string): void
  • Parameters

    • value: any
    • Default value valueName: string = ""
    • Default value errorMessage: string = "must be a non empty string"

    Returns void

    void

Static forceString

  • forceString(value: any, valueName?: string, errorMessage?: string): void
  • Parameters

    • value: any
    • Default value valueName: string = ""
    • Default value errorMessage: string = "must be a string"

    Returns void

    void

Static formatCase

  • formatCase(string: string, format: string): string
  • Parameters

    • string: string
    • format: string

    Returns string

    The given string converted to the specified case format.

Static formatForFullTextSearch

  • formatForFullTextSearch(): void
  • Returns void

Static formatPath

  • formatPath(path: any, separator?: string): string
  • Parameters

    • path: any
    • Default value separator: string = "/"

    Returns string

    The correctly formatted path without any trailing separator

Static formatUrl

  • formatUrl(url: string): string
  • Parameters

    • url: string

    Returns string

    The formated url string or the original string if it was not a valid url

Static generateRandom

  • generateRandom(minLength: number, maxLength: number, charSet?: string[]): string
  • Parameters

    • minLength: number
    • maxLength: number
    • Default value charSet: string[] = ['0-9', 'a-z', 'A-Z']

    Returns string

    A randomly generated string

Static getDomainFromUrl

  • getDomainFromUrl(url: string): any
  • Parameters

    • url: string

    Returns any

    The domain from the given string (excluding the subdomain if exists)

Static getHostNameFromUrl

  • getHostNameFromUrl(url: string): string
  • Parameters

    • url: string

    Returns string

    The domain and subdomain from the given string (subdomain.domain.com)

Static getKeyWords

  • getKeyWords(): void
  • Returns void

Static getLines

  • getLines(string: string, filters?: RegExp[]): string[]
  • Parameters

    • string: string
    • Default value filters: RegExp[] = [/\s+/g]

    Returns string[]

    A list with all the string lines sepparated as different array elements.

Static getPath

  • getPath(path: string, elementsToRemove?: number, separator?: string): string
  • Parameters

    • path: string
    • Default value elementsToRemove: number = 1
    • Default value separator: string = "/"

    Returns string

    The received path without the specified number of elements and correctly formatted

Static getPathElement

  • getPathElement(path: string, position?: number): string
  • Parameters

    • path: string
    • Default value position: number = -1

    Returns string

    The element at the specified path position or the last one if no position is defined

Static getPathElementWithoutExt

  • getPathElementWithoutExt(path: string, position?: number, extensionSeparator?: string): string
  • Parameters

    • path: string
    • Default value position: number = -1
    • Default value extensionSeparator: string = "."

    Returns string

    The element at the specified path position with it's extension removed or the last one if no position is defined

Static getPathExtension

  • getPathExtension(path: string, position?: number, extensionSeparator?: string): string
  • Parameters

    • path: string
    • Default value position: number = -1
    • Default value extensionSeparator: string = "."

    Returns string

    The extension from the element at the specified path position or the extension from the last one if no position is defined

Static getSchemeFromUrl

  • getSchemeFromUrl(url: string): string
  • Parameters

    • url: string

    Returns string

    ('ftp', 'http', ...) if the url is valid or '' if the url is invalid

Static isCamelCase

  • isCamelCase(): void
  • Returns void

Static isEmpty

  • isEmpty(string: string, emptyChars?: string[]): boolean
  • Parameters

    • string: string
    • Default value emptyChars: string[] = []

    Returns boolean

    false if the string is not empty, true if the string contains non semantically valuable characters or any other characters defined as "empty" values

Static isSnakeCase

  • isSnakeCase(): void
  • Returns void

Static isString

  • isString(value: any): boolean
  • Parameters

    • value: any

    Returns boolean

    true if the given value is a string, false otherwise

Static isUrl

  • isUrl(value: any): boolean
  • Parameters

    • value: any

    Returns boolean

    False in case the validation fails or true if validation succeeds.

Static limitLen

  • limitLen(string: string, limit?: number, limiterString?: string): string
  • Parameters

    • string: string
    • Default value limit: number = 100
    • Default value limiterString: string = " ..."

    Returns string

    The specified string but limited in length if necessary. Final result will never exceed the specified limit, also with the limiterString appended.

Static pad

  • pad(string: string, padLength: number, padString?: string, mode?: string): string
  • Parameters

    • string: string
    • padLength: number
    • Default value padString: string = "0"
    • Default value mode: string = "LEFT"

    Returns string

    The padded string

Static removeAccents

  • removeAccents(string: string): string
  • Parameters

    • string: string

    Returns string

    The given string with all accent and diacritics replaced by the respective ASCII characters.

Static removeHtmlCode

  • removeHtmlCode(): void
  • Returns void

Static removeNewLineCharacters

  • removeNewLineCharacters(): void
  • Returns void

Static removeSameConsecutive

  • removeSameConsecutive(): void
  • Returns void

Static removeUrls

  • removeUrls(): void
  • Returns void

Static removeWordsLongerThan

  • removeWordsLongerThan(): void
  • Returns void

Static removeWordsShorterThan

  • removeWordsShorterThan(): void
  • Returns void

Static replace

  • replace(string: string, search: string | string[], replacement: string | string[], count?: number): string
  • Parameters

    • string: string
    • search: string | string[]
    • replacement: string | string[]
    • Default value count: number = -1

    Returns string

    The string with all the replaced values

Static trim

  • trim(string: string, characters?: string): string
  • Parameters

    • string: string
    • Default value characters: string = ""

    Returns string

    The trimmed string

Static trimLeft

  • trimLeft(string: string, characters?: string): string
  • Parameters

    • string: string
    • Default value characters: string = ""

    Returns string

    The trimmed string

Static trimRight

  • trimRight(string: string, characters?: string): string
  • Parameters

    • string: string
    • Default value characters: string = ""

    Returns string

    The trimmed string

Generated using TypeDoc