Skip to content

Latest commit

 

History

History
63 lines (41 loc) · 1.08 KB

strip.md

File metadata and controls

63 lines (41 loc) · 1.08 KB

strip

Trim whitespace from the ends of a string.

API

Numeric.string.strip(text, mode = 'both')

Trims characters from one or both ends.

  • Parameters:
    • text: String or array of strings to trim
    • mode: Side or sides that are trimmed
  • Returns: Trimmed strings matching the input shape
  • NumPy: Covers np.strings.strip, np.strings.lstrip, np.strings.rstrip, np.char.strip, np.char.lstrip, np.char.rstrip through a single Numerix method.

Examples

Trim both ends

import Numeric from '@neabyte/numerix'

const value = Numeric.string.strip('  ab  ')

console.log(value)
// ab

Trim the left end

import Numeric from '@neabyte/numerix'

const value = Numeric.string.strip('  ab  ', 'left')

console.log(value)
// ab

Trim the right end

import Numeric from '@neabyte/numerix'

const value = Numeric.string.strip('  ab  ', 'right')

console.log(value)
//   ab

Trim an array of strings

import Numeric from '@neabyte/numerix'

const values = Numeric.string.strip([' a ', ' b '])

console.log(values)
// ["a","b"]