Pad a string to a fixed width.
Numeric.string.align(text, width, mode = 'center', fill = ' ')Pads text using the requested alignment mode.
- Parameters:
text: String or array of strings to alignwidth: Target width of the aligned textmode: Alignment mode applied to each stringfill: 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)
// abimport 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)
// abimport Numeric from '@neabyte/numerix'
const value = Numeric.string.align('42', 6, 'zero')
console.log(value)
// 000042