Split a string around a separator.
Numeric.string.partition(text, separator, reverse = false)Reports the text before and after the separator.
- Parameters:
text: String or array of strings to partitionseparator: Separator marking the split positionreverse: When true splits at the last separator
- Returns: Partitioned parts matching the input shape
- NumPy: Covers
np.strings.partition,np.strings.rpartition,np.char.partition,np.char.rpartitionthrough a single Numerix method.
import Numeric from '@neabyte/numerix'
const parts = Numeric.string.partition('a-b', '-')
console.log(parts)
// ["a","-","b"]import Numeric from '@neabyte/numerix'
const parts = Numeric.string.partition('abc', '-')
console.log(parts)
// ["abc","",""]import Numeric from '@neabyte/numerix'
const parts = Numeric.string.partition('a-b-c', '-', true)
console.log(parts)
// ["a-b","-","c"]import Numeric from '@neabyte/numerix'
const parts = Numeric.string.partition(['a-b', 'c-d'], '-')
console.log(parts)
// [["a","-","b"],["c","-","d"]]