GithubNPM
Options
All
  • Public
  • Public/Protected
  • All
Menu

Package with operators for generating Observable, filtering, querying and parsing strings in RxJS

String Module

References

padLeft:alias of padStart
padRight:alias of padEnd
trimLeft:alias of trimStart
trimRight:alias of trimEnd

Variables

NO_CAP_WORDS: string[] = ...

Default words to exclude when using the titleize operator

Convert Functions

  • join(separator?: Subscribable<string> | string): OperatorFunction<Iterable<unknown>, string>
  • Returns an Observable that emits a string value from an Array or Set of values joined to a single string using the separator.

    typeparam

    The type of value in the source Array or Map

    Parameters

    • separator: Subscribable<string> | string = ' '

      The character to join text with, default is a space character

    Returns OperatorFunction < Iterable < unknown > , string >

    Observable that emits a string from an Array or`Set of values

  • split(separator?: Subscribable<string> | string, limit?: Subscribable<number> | number): OperatorFunction<string, string[]>
  • Returns an Observable that emits an array from a source string split by the separator using String.split

    example

    Returns an array of a string split on the | character

    of('Hello|World|RxJS|Ninja').pipe(split('|')).subscribe();
    

    Output: ['Hello', 'World', 'RxJS', 'Ninja']

    example

    Returns an array of a string split on the | character, limiting to the first 2

    of('Hello|World|RxJS|Ninja').pipe(split('|', 2)).subscribe();
    

    Output: ['Hello', 'World']

    Parameters

    • separator: Subscribable<string> | string = ' '

      The character to split the string at

    • Optional limit: Subscribable<number> | number

      Optional limit for the number of times to split

    Returns OperatorFunction < string , string [] >

    Observable that emits an array of strings from the source string split on the separator

Create Functions

  • fromCharCode(input: Subscribable<Iterable<number> | number> | Iterable<number> | number): Observable<string>
  • Returns an Observable that emits a string made from character codes using String.fromCharCode

    remarks

    This operator will emit a single string for all input passed including arrays

    see

    The mapCharCode operator can be used to map an Observable source of char codes to strings

    example

    Return a string from character code array

    fromCharCode([82, 120, 74, 83]).subscribe();
    

    Output: RxJS

    example

    Return a string from character code Observable

    fromCharCode(of([82, 120, 74, 83]).subscribe();
    

    Output: RxJS

    Parameters

    • input: Subscribable<Iterable<number> | number> | Iterable<number> | number

      Single or list of character codes to convert to a string

    Returns Observable < string >

    Observable that emits a string

  • fromCodePoint(input: Subscribable<Iterable<number> | number> | Iterable<number> | number): Observable<string>
  • Returns an Observable that emits a string made from code points using String.fromCodePoint

    remarks

    This operator will emit a single string for all input passed including arrays

    example

    Return a string from code points array

    fromCodePoint([9731, 9733, 9842]).subscribe();
    

    Output: ☃★♲

    example

    Return a string from code points Observable

    fromCodePoint(of([9731, 9733, 9842]).subscribe();
    

    Output: ☃★♲

    Parameters

    • input: Subscribable<Iterable<number> | number> | Iterable<number> | number

      Single or list of code points to convert to a string

    Returns Observable < string >

    Observable that emits a string

  • fromString(input: Subscribable<Iterable<string> | string> | Iterable<string> | string): Observable<string>
  • Returns an Observable that emits strings from any an argument list of strings or supported Observable, Promise or Array-like source

    remarks

    This operator is a type-safe from and will emit only strings, also unlike from a single string is not converted into an array-like.

    example

    Return a reversed string from an array list of strings

    fromString(['RxJS', 'Ninja']).pipe(reverse()).subscribe();
    

    Output: 'SJxR', 'ajniN'

    example

    Return a reversed string from an Observable array list of strings

    fromString(of(['RxJS', 'Ninja'])).pipe(reverse()).subscribe();
    

    Output: 'SJxR', 'ajniN'

    Parameters

    • input: Subscribable<Iterable<string> | string> | Iterable<string> | string

      Argument list, Observable input, Promise or Array of strings

    Returns Observable < string >

    Observable that emits a string

  • fromUnicode(input: Subscribable<Iterable<string> | string> | Iterable<string> | string, form?: FormType): Observable<string>
  • Returns an Observable that emits a string made from a source unicode string using String.normalize

    remarks

    This operator is a type-safe from and will emit only strings, also unlike from a single string is not converted into an array-like.

    example

    Returns a string from Unicode characters

    fromUnicode('\u0041\u006d\u00e9\u006c\u0069\u0065').subscribe();
    

    Output: Amélie

    Parameters

    • input: Subscribable<Iterable<string> | string> | Iterable<string> | string

      Single or list of Unicode character to convert to a string

    • Optional form: FormType

      The Unicode Normalization Form to decode the string with

    Returns Observable < string >

    Observable that emits a string

Filter Functions

  • filterEndsWith(search: Subscribable<string> | string, maxLength?: Subscribable<number> | number): MonoTypeOperatorFunction<string>
  • Returns an Observable that emits a string where the source string ends with the passed ending using String.endsWith

    see

    The endsWith operator returns the boolean value

    example

    Return a string where the source string ends with the S character

    from(['RxJS', 'Ninja', 'Tests']).pipe(filterEndsWith('S')).subscribe();
    

    Output: RxJS

    example

    Return a string where the source string at up to length 4 ends with the t character

    from(['RxJS', 'Ninja', 'Tests']).pipe(filterEndsWith('t', 4)).subscribe();
    

    Output: Tests

    Parameters

    • search: Subscribable<string> | string

      The string to check the source ends with

    • Optional maxLength: Subscribable<number> | number

      Optional length of the string to check

    Returns MonoTypeOperatorFunction < string >

    Observable that emits a string

  • filterIncludes(search: Subscribable<string> | string): MonoTypeOperatorFunction<string>
  • Returns an Observable that emits a string where the source string contains with the passed search string using String.includes

    see

    The includes operator returns the boolean value

    example

    Return a string where the source string includes 'JS'

    from(['RxJS', 'Ninja', 'Tests']).pipe(filterIncludes('JS')).subscribe();
    

    Output: RxJS

    Parameters

    • search: Subscribable<string> | string

      The string to check the source ends with

    Returns MonoTypeOperatorFunction < string >

    Observable that emits a string

  • filterStartsWith(search: Subscribable<string> | string, startIndex?: Subscribable<number> | number): MonoTypeOperatorFunction<string>
  • Returns an Observable that emits a string where the source string starts with the passed string using String.startsWith

    see

    The startsWith operator returns the boolean value

    example

    Return a string where the source string starts with the N character

    from(['RxJS', 'Ninja', 'Tests']).pipe(filterStartsWith('N')).subscribe();
    

    Output: Ninja

    example

    Return a string where the source string starts with t character from index 3

    from(['RxJS', 'Ninja', 'Tests']).pipe(filterStartsWith('t', 3)).subscribe();
    

    Output: Tests

    Parameters

    • search: Subscribable<string> | string

      The string to check the source starts with

    • Optional startIndex: Subscribable<number> | number

      Optional index to start the check from

    Returns MonoTypeOperatorFunction < string >

    Observable that emits a string

Mapping Functions

  • mapCharCode(): OperatorFunction<Iterable<number> | number, string>
  • Returns an Observable that emits a string from a source of character codes using String.fromCharCode

    see

    The fromCharCode Observable can be used to generate a string source from character codes

    example

    Returns a string RxJS from a source array of character codes

    of([82, 120, 74, 83]).pipe(mapCharCode()).subscribe()
    

    Output: RxJS

    Returns OperatorFunction < Iterable < number > | number , string >

    Observable that emits a string from source character codes

  • mapCodePoint(): OperatorFunction<Iterable<number> | number, string>
  • Returns an Observable that emits a string from a source of character codes using String.fromCodePoint

    see

    The fromCodePoint Observable can be used to generate a string source from character codes

    example

    Returns a string RxJS from a source array of code points

    of([9731, 9733, 9842]).pipe(mapCodePoint()).subscribe()
    

    Output: ☃★♲

    Returns OperatorFunction < Iterable < number > | number , string >

    Observable that emits a string from source code points

  • normalize(form?: Subscribable<FormType> | FormType): MonoTypeOperatorFunction<string>
  • Returns an Observable that emits a string made from a source unicode string using String.normalize

    example

    Returns a string from Unicode characters

    of('\u0041\u006d\u00e9\u006c\u0069\u0065').pipe(normalize()).subscribe();
    

    Output: Amélie

    Parameters

    • Optional form: Subscribable<FormType> | FormType

      The Unicode Normalization Form to decode the string with

    Returns MonoTypeOperatorFunction < string >

    Observable that emits a string

Modify Functions

  • concat(input: Subscribable<Iterable<string> | string> | Iterable<string> | string): MonoTypeOperatorFunction<string>
  • Returns an Observable that emits a string that is the source string concatenated with the passed input to the operator using Sting.concat

    example

    Return a string that is a source appended with a string

    of('RxJS').pipe(concat('Ninja')).subscribe();
    

    Output: RxJSNinja

    example

    Return a string that is a source appended with a array of strings

    of('RxJS').pipe(concat([' ', 'Ninja'])).subscribe();
    

    Output: RxJS Ninja

    example

    Return a string that is a source appended with an Observable strings

    of('RxJS').pipe(concat(of([' ', 'Ninja']))).subscribe();
    

    Output: RxJS Ninja

    Parameters

    • input: Subscribable<Iterable<string> | string> | Iterable<string> | string

      Single or list of arguments to concatenate with the source string

    Returns MonoTypeOperatorFunction < string >

    Observable that emits a string

  • padEnd(maxLength: Subscribable<number> | number, fillString?: Subscribable<string> | string): MonoTypeOperatorFunction<string>
  • Returns an Observable that emits a string where the source string has been padded using String.padEnd

    alias

    padRight

    example

    Returns a string padded to a length of 12 with default fill string

    of('RxJS Ninja').pipe(padEnd(12)).subscribe();
    

    Output: 'RxJS Ninja '

    example

    Returns a string padded to a length of 12 with . fill string

    of('12345').pipe(padEnd(12, '.')).subscribe();
    

    Output: 'RxJS Ninja..'

    Parameters

    • maxLength: Subscribable<number> | number

      The maximum length to pad the string to

    • Optional fillString: Subscribable<string> | string

      Optional string to use as the string padding

    Returns MonoTypeOperatorFunction < string >

    Observable that emits a string that is padded to the passed length

  • padStart(maxLength: Subscribable<number> | number, fillString?: Subscribable<string> | string): MonoTypeOperatorFunction<string>
  • Returns an Observable that emits a string where the source string has been padded using String.padStart

    alias

    padLeft

    example

    Returns a string padded to a length of 12 with default fill string

    of('RxJS Ninja').pipe(padStart(12)).subscribe();
    

    Output: ' RxJS Ninja'

    example

    Returns a string padded to a length of 12 with . fill string

    of('12345').pipe(padStart(12, '.')).subscribe();
    

    Output: '..RxJS Ninja'

    Parameters

    • maxLength: Subscribable<number> | number

      The maximum length to pad the string to

    • Optional fillString: Subscribable<string> | string

      Optional string to use as the string padding

    Returns MonoTypeOperatorFunction < string >

    Observable that emits a string that is padded to the passed length

  • repeat(count: Subscribable<number> | number, separator?: Subscribable<string> | string): MonoTypeOperatorFunction<string>
  • Returns an Observable that emits a string where the source string is repeated with String.repeat.

    remarks

    If a separator is passed it uses an array and will join the result using the separator instead, as String.repeat does not support it

    example

    Returns a string with the word Ninja repeated 5 times

    of('Ninja').pipe(repeat(5)).subscribe();
    

    Output: NinjaNinjaNinjaNinjaNinja

    example

    Returns a string with the word Ninja repeated 5 times with a , separator

    of('Ninja').pipe(repeat(5, ', ')).subscribe();
    

    Output: Ninja, Ninja, Ninja, Ninja, Ninja

    Parameters

    • count: Subscribable<number> | number

      The number of times to repeat the string

    • Optional separator: Subscribable<string> | string

      Optional separator for joining strings

    Returns MonoTypeOperatorFunction < string >

    Observable that emits a string of the source string repeated

  • replace(pattern: Subscribable<string | RegExp> | string | RegExp, replacement: Subscribable<string> | string): MonoTypeOperatorFunction<string>
  • Returns an Observable that emits a string, replacing text in the source string with the replacement text if the pattern is found using String.replace

    example

    Return a string with first instance Hero replaced with Ninja

    of('RxJS Hero, Angular Hero').pipe(replace('Hero', 'Ninja')).subscribe();
    

    Output: RxJS Ninja, Angular Hero

    example

    Return a string where Hero is replaced with Ninja using a RegExp

    of('RxJS Hero, Angular Hero').pipe(replace(/(?!\w+\s)(\w+)/, 'Ninja')).subscribe();
    

    Output: RxJS Ninja, Angular Hero

    Parameters

    • pattern: Subscribable<string | RegExp> | string | RegExp

      A string or RegExp to find in the Observable string to replace

    • replacement: Subscribable<string> | string

      The replacement string

    Returns MonoTypeOperatorFunction < string >

    Observable that emits a string

  • replaceAll(pattern: Subscribable<string | RegExp> | string | RegExp, replacement: Subscribable<string> | string): MonoTypeOperatorFunction<string>
  • Returns an Observable that emits a string, replacing text in the source string with the replacement text if the pattern is found using String.replaceAll

    example

    Return a string with all instances of Hero replaced with Ninja

    of('RxJS Hero, Angular Hero').pipe(replaceAll('Hero', 'Ninja')).subscribe();
    

    Output: RxJS Ninja, Angular Ninja

    example

    Return a string where Hero is replaced with Ninja using a RegExp

    of('RxJS Hero, Angular Hero').pipe(replaceAll(/(?!\w+\s)(\w+)/g, 'Ninja')).subscribe();
    

    Output: RxJS Ninja, Angular Ninja

    Parameters

    • pattern: Subscribable<string | RegExp> | string | RegExp

      A string or RegExp to find in the Observable string to replace

    • replacement: Subscribable<string> | string

      The replacement string

    Returns MonoTypeOperatorFunction < string >

    Observable that emits a string

  • reverse(): MonoTypeOperatorFunction<string>
  • Returns an Observable that emits a string where the source string is reversed.

    remarks

    This operator turns a string into an array and uses Array.reverse and Array.join to create a new string

    example

    Returns a string that is reversed

    of('emordnilaP').pipe(reverse()).subscribe();
    

    Output: 'Palindrome'

    Returns MonoTypeOperatorFunction < string >

    Observable that emits a string that is reversed from the source

  • slice(startIndex: Subscribable<number> | number, endIndex?: Subscribable<number> | number): MonoTypeOperatorFunction<string>
  • Returns an Observable that emits a string that is a partial slice of the source string using String.slice

    remarks

    For creating substrings use substring as a better alternative to slice

    example

    Return a string from index 0 to 4

    of('RxJS Ninja').pipe(slice(0, 4)).subscribe();
    

    Output: RxJS

    example

    Return a string from index 5 to the end of the string

    of('RxJS Ninja').pipe(slice(5)).subscribe();
    

    Output: Ninja

    Parameters

    • startIndex: Subscribable<number> | number

      The start index for the substring

    • Optional endIndex: Subscribable<number> | number

      Optional end index for the length of substring, if not passed slice will use str.length -1

    Returns MonoTypeOperatorFunction < string >

    Observable that emits a string that is a slice of the source string

  • substring(indexStart: Subscribable<number> | number, indexEnd?: Subscribable<number> | number): MonoTypeOperatorFunction<string>
  • Returns an Observable that emits a string that is a partial slice of the source string using String.substring

    example

    Return a string from index 0 to 4

    of('RxJS Ninja').pipe(substring(0, 4)).subscribe();
    

    Output: RxJS

    example

    Return a string from index 5 to the end of the string

    of('RxJS Ninja').pipe(substring(5)).subscribe();
    

    Output: Ninja

    Parameters

    • indexStart: Subscribable<number> | number

      The index of the first character to include in the returned substring.

    • Optional indexEnd: Subscribable<number> | number

      Optional The index of the first character to exclude from the returned substring.

    Returns MonoTypeOperatorFunction < string >

    Observable that emits a string that is a substring of the source string

  • titleize(noTitleWords?: Subscribable<Iterable<string>> | Iterable<string>, separator?: Subscribable<string> | string, locales?: Subscribable<string> | string): MonoTypeOperatorFunction<string>
  • Return an Observable that emits a string where the source string is titleized (first letter of each word uppercase). The operator uses String.toLocaleUpperCase so can support locale strings

    By default is uses the NO_CAP_WORDS to skip some words (unless they are the first word in the string). To disable this pass an empty array, and to extend you can use the default with a spread operator to extend: [...NO_CAP_WORDS, 'foo', 'bar']. When using a separator, if no change in default pass undefined

    It will also skip words already starting with a capital (e.g. <a href="https://rxjs.dev" target="_blank">RxJS</a>)

    example

    Returns a string titilzed with default no caps words

    of('the RxJS ninja').pipe(titleize()).subscribe();
    

    Output: The RxJS Ninja

    example

    Returns a string titilzed with additional no cap words

    of('the RxJS ninja').pipe(titleize([...NO_CAP_WORDS, 'ninja'])).subscribe();
    

    Output: The RxJS ninja

    example

    Returns a string titilzed with a separator

    of('angular,RxJS,typescript,ninja').pipe(titleize(undefined, ',')).subscribe();
    

    Output: Angular,RxJS,Typescript,Ninja

    example

    Returns a string titilzed with a different locale

    of('ängulär,RxJS,typescript,ninjä').pipe(titleize(undefined, undefined, 'de-DE')).subscribe();
    

    Output: Ängulär,RxJS,Typescript,Ninjä

    Parameters

    • noTitleWords: Subscribable<Iterable<string>> | Iterable<string> = ...

      A list of words to exclude from making a title word

    • separator: Subscribable<string> | string = ' '

      Optional separator to use when joining each word

    • Optional locales: Subscribable<string> | string

      Locales for string formatting

    Returns MonoTypeOperatorFunction < string >

    Observable that emits a titilzed string

  • toLowerCase(locales?: Subscribable<Iterable<string> | string> | Iterable<string> | string): MonoTypeOperatorFunction<string>
  • Returns an Observable that emits a string where the source string is passed through String.toLocaleLowerCase

    example

    Returns an lower case string

    of('APPLE').pipe(toLowerCase()).subscribe();
    

    Output: 'apple'

    example
    • Returns an lower case string with locale
      of('ÄPFEL').pipe(toLowerCase('de-DE')).subscribe();
      
      Output: 'äpfel'

    Parameters

    • Optional locales: Subscribable<Iterable<string> | string> | Iterable<string> | string

      Optional locales to pass for string formatting

    Returns MonoTypeOperatorFunction < string >

    Observable that emits a lower case string

  • toUpperCase(locales?: Subscribable<Iterable<string> | string> | Iterable<string> | string): MonoTypeOperatorFunction<string>
  • Returns an Observable that emits a string where the source string is passed through String.toLocaleLowerCase

    example

    Returns an upper case string

    of('apple').pipe(toUpperCase()).subscribe();
    

    Output: 'APPLE'

    example

    Returns an lower case string with locale

    of('äpfel').pipe(toUpperCase('de-DE')).subscribe();
    

    Output: 'ÄPFEL'

    Parameters

    • Optional locales: Subscribable<Iterable<string> | string> | Iterable<string> | string

      Optional locales to pass for string formatting

    Returns MonoTypeOperatorFunction < string >

    Observable that emits a lower case string

  • trim(): MonoTypeOperatorFunction<string>
  • Returns an Observable that emits a string where the source string has any white space at the ends removed using String.trim

    example

    Returns the source string with any whitespace at both ends removed

    of('  RxJS Ninja  ').pipe(trimStart()).subscribe();
    

    Output: 'RxJS Ninja'

    Returns MonoTypeOperatorFunction < string >

    Observable that emits a trimmed string

  • trimEnd(): MonoTypeOperatorFunction<string>
  • Returns an Observable that emits a string where the source string has any white space at the end removed using String.trimEnd

    alias

    trimRight

    example

    Returns the source string with any whitespace at the end removed

    of('  RxJS Ninja  ').pipe(trimStart()).subscribe();
    

    Output: ' RxJS Ninja'

    Returns MonoTypeOperatorFunction < string >

    Observable that emits a trimmed string

  • trimStart(): MonoTypeOperatorFunction<string>
  • Returns an Observable that emits a string where the source string has any white space at the start removed using String.trimStart

    alias

    trimLeft

    example

    Returns the source string with any whitespace at the start removed

    of('  RxJS Ninja  ').pipe(trimStart()).subscribe();
    

    Output: 'RxJS Ninja '

    Returns MonoTypeOperatorFunction < string >

    Observable that emits a trimmed string

Query Functions

  • charAt(positions: Subscribable<Iterable<number> | number> | Iterable<number> | number): OperatorFunction<string, string[]>
  • Returns an Observable that emits an array of strings. The string is returned from String.charAt using the passed index or array of indexes. The output is always an Array containing the string, or empty string if nothing found.

    example

    Return the character at index 1

    of('RxJS Ninja').pipe(charAt(1)).subscribe();
    

    Output: ['x']

    example

    Return the character at index 1 and 7

    of('RxJS Ninja').pipe(charAt([1, 7])).subscribe();
    

    Output: ['x', 'n']

    Parameters

    • positions: Subscribable<Iterable<number> | number> | Iterable<number> | number

      Single or list of index values to return the character at

    Returns OperatorFunction < string , string [] >

    Observable that emits an Array of string values

  • charCodeAt(positions: Subscribable<Iterable<number> | number> | Iterable<number> | number): OperatorFunction<string, number[]>
  • Returns an Observable that emits an array of numbers. The number is returned from String.charCodeAt using the passed index or array of indexes. The output is always an Array containing the number, or NaN.

    example

    Return the character code of the character at index 1

    of('RxJS Ninja').pipe(charCodeAt(1)).subscribe();
    

    Output: 120

    Parameters

    • positions: Subscribable<Iterable<number> | number> | Iterable<number> | number

      Single or list of index values to return the character at

    Returns OperatorFunction < string , number [] >

    Observable that emits an Array of number values

  • codePointAt(positions: Subscribable<Iterable<number> | number> | Iterable<number> | number): OperatorFunction<string, number[]>
  • Returns an Observable that emits an array of numbers. The number is returned from String.codePointAt using the passed index or array of indexes. The output is always an Array containing the number, or NaN.

    remarks

    By default String.codePointAt returns undefined, this operator returns NaN instead matching charCodeAt

    example

    Return the code point of the character at index 1

    of('☃★♲').pipe(codePointAt(1)).subscribe();
    

    Output: 9733

    Parameters

    • positions: Subscribable<Iterable<number> | number> | Iterable<number> | number

      Single or list of index values to return the character at

    Returns OperatorFunction < string , number [] >

    Observable that emits a number that is a code point

  • endsWith(search: Subscribable<string> | string, maxLength?: Subscribable<number> | number): OperatorFunction<string, boolean>
  • Returns an Observable that emits a boolean value where the source string ends with the passed string parameter using String.endsWith

    see

    The filterEndsWith operator returns the string value

    example

    Return if the source string ends with the S character

    from(['RxJS', 'Ninja', 'Tests']).pipe(endsWith('S')).subscribe();
    

    Output: true, false, false

    example

    Return if the source string at up to length 4 ends with the t character

    from(['RxJS', 'Ninja', 'Tests']).pipe(endsWith('t', 4)).subscribe();
    

    Output: false, false, true

    Parameters

    • search: Subscribable<string> | string

      The string to check the source ends with

    • Optional maxLength: Subscribable<number> | number

      Optional length of the string to check

    Returns OperatorFunction < string , boolean >

    Observable that emits a boolean of the source string ending with the passed input

  • includes(search: Subscribable<string> | string): OperatorFunction<string, boolean>
  • Returns an Observable that emits a boolean where the source string contains with the passed search string using String.includes

    see

    The filterIncludes operator returns the string value

    example

    Return a boolean where the source string includes 'JS'

    from(['RxJS', 'Ninja', 'Tests']).pipe(includes('JS')).subscribe();
    

    Output: true, false, false

    Parameters

    • search: Subscribable<string> | string

      The string to check the source ends with

    Returns OperatorFunction < string , boolean >

    Observable that emits a boolean

  • indexOf(search: Subscribable<string> | string, startIndex?: Subscribable<number> | number): OperatorFunction<string, number>
  • Returns an Observable that emits a number of the first index from the source string where the search string begins using String.indexOf

    example

    Returns the first index of RxJS in the string

    of('Hello RxJS Ninja, RxJS Rocks').pipe(indexOf('RxJS')).subscribe();
    

    Output: 6

    example

    Returns the first index of RxJS in the string, starting from index 8

    of('Hello RxJS Ninja, RxJS Rocks').pipe(indexOf('RxJS', 8)).subscribe();
    

    Output: 18

    Parameters

    • search: Subscribable<string> | string

      The string to search in the source string

    • Optional startIndex: Subscribable<number> | number

      Optional start position if not from the beginning of the string

    Returns OperatorFunction < string , number >

    Observable that emits a number that is the first index of the search string in the source string

  • lastIndexOf(search: Subscribable<string> | string, lastIndex?: Subscribable<number> | number): OperatorFunction<string, number>
  • Returns an Observable that emits a number of the last index from the source string where the search string begins using String.lastIndexOf

    example

    Returns the first index of RxJS in the string

    of('Hello RxJS Ninja, RxJS Rocks').pipe(lastIndexOf('RxJS')).subscribe();
    

    Output: 18

    example

    Returns the first index of RxJS in the string, ending at index 15

    of('Hello RxJS Ninja, RxJS Rocks').pipe(lastIndexOf('RxJS', 15)).subscribe();
    

    Output: 6

    Parameters

    • search: Subscribable<string> | string

      The string to search in the source string

    • Optional lastIndex: Subscribable<number> | number

      The index of the last character in the string to search up to

    Returns OperatorFunction < string , number >

    Observable that emits a number that is the last index of the search string in the source string

  • match(pattern: Subscribable<string | RegExp> | string | RegExp): OperatorFunction<string, RegExpMatchArray | null>
  • Returns an Observable that emits a RegExpMatchArray where a source string returns a valid result using using String.match. If no result is found, null is emitted.

    example

    Returns a single match for the string RxJS in the source string

    of('Hello RxJS Ninja, RxJS Rocks').pipe(match('RxJS')).subscribe();
    

    Output: ['RxJS', index: 6, input: 'Hello RxJS Ninja, RxJS Rocks', groups: undefined]

    example

    Returns a match with a RegExp with global /g for RxJS

    of('Hello RxJS Ninja, RxJS Rocks').pipe(match(/RxJS/g)).subscribe();
    

    Output: ['RxJS', 'RxJS']

    Parameters

    • pattern: Subscribable<string | RegExp> | string | RegExp

      A string or RegExp to match

    Returns OperatorFunction < string , RegExpMatchArray | null >

    Observable that emits a RegExpMatchArray

  • matchAll(pattern: Subscribable<RegExp> | RegExp): OperatorFunction<string, RegExpMatchArray[]>
  • Returns an Observable that emits an array of results from String.matchAll

    remarks

    This operator converts the IterableIterator<RegExpMatchArray> to RegExpMatchArray[] to avoid dealing with iterators.

    example

    Returns all matching groups in the source string

    of('RxJS Ninja,Hello Ninja').pipe(matchAll(/([A-Za-z\s]*)Ninja/g).subscribe();
    

    Output:["RxJS Ninja", index: 0, input: "RxJS Ninja,Hello Ninja"], ["Hello Ninja", index: 11, input: "RxJS Ninja,Hello Ninja"]

    Parameters

    • pattern: Subscribable<RegExp> | RegExp

      A RegExp regular expression to match in the string

    Returns OperatorFunction < string , RegExpMatchArray [] >

    Observable that emits an array of RegExpMatchArray

  • search(pattern: Subscribable<string | RegExp> | string | RegExp): OperatorFunction<string, number>
  • Returns an Observable that emits a number that is the first index of where the value is found using String.search

    example

    Return the first index of Ninja

    of('RxJS Ninja, Angular Ninja').pipe(search('Ninja')).subscribe();
    

    Output: 5

    example

    Return the first index of the first found group from the RegExp

    of('RxJS Ninja, Angular Ninja').pipe(search(/(?!\w+\s)(\w+)/g)).subscribe();
    

    Output: 5

    Parameters

    • pattern: Subscribable<string | RegExp> | string | RegExp

      A string or RegExp to match in the string

    Returns OperatorFunction < string , number >

    Observable that emits an number that is the start index of the first found value

  • startsWith(search: Subscribable<string> | string, startIndex?: Subscribable<number> | number): OperatorFunction<string, boolean>
  • Returns an Observable that emits a boolean when the source string contains the input string at the start of the source string using String.startsWith

    remarks

    If you need to get the string value instead of boolean use filterStartsWith

    example

    Return a boolean if the source string starts with the passed input

    from(['RxJS', 'Ninja', 'Hero']).pipe(startsWith('R')).subscribe();
    

    Output: true, false, false

    example

    Return a boolean if the source string starts with the passed input from index 1

    from(['RxJS', 'Ninja', 'Hero']).pipe(startsWith('x', 1)).subscribe();
    

    Output: true, false, false

    Parameters

    • search: Subscribable<string> | string

      The string to check the source string start with

    • Optional startIndex: Subscribable<number> | number

      Optional start index to being searching the string from

    Returns OperatorFunction < string , boolean >

    Observable that emits a boolean if the source string start with the input string

Generated using TypeDoc, the 08/02/2021 at 13:47:36