Pad a string to a fixed width.
Numeric.string.align(input, width, method = 'center', filler = ' ')Pads text using the requested alignment mode.
- Parameters:
input: String or array of strings to alignwidth: Target width of the aligned textmethod: Alignment method applied to each stringfiller: Character used to fill the padding
- Returns: Aligned strings matching the input shape
- NumPy: Covers
np.strings.center,np.strings.ljust,np.strings.rjust,np.strings.zfill,np.char.center,np.char.ljust,np.char.rjust,np.char.zfillthrough a single Numerix method.
import Numeric from '@neabyte/numerix'
const value = Numeric.string.align('ab', 6, 'left')
console.log(value)
// ab (followed by four spaces)import Numeric from '@neabyte/numerix'
const value = Numeric.string.align('ab', 6, 'right')
console.log(value)
// abimport Numeric from '@neabyte/numerix'
const value = Numeric.string.align('ab', 6, 'center')
console.log(value)
// ab (followed by two spaces)import Numeric from '@neabyte/numerix'
const value = Numeric.string.align('42', 6, 'zero')
console.log(value)
// 000042