Find the position of a substring in a string.
Numeric.string.find(text, needle, reverse = false)Reports the index of the first or last occurrence.
- Parameters:
text: String or array of strings to searchneedle: Substring whose position is reportedreverse: When true searches from the end
- Returns: Match positions matching the input shape
- NumPy: Covers
np.strings.find,np.strings.rfind,np.strings.index,np.strings.rindex,np.char.find,np.char.rfind,np.char.index,np.char.rindexthrough a single Numerix method.
import Numeric from '@neabyte/numerix'
const index = Numeric.string.find('hello', 'l')
console.log(index)
// 2import Numeric from '@neabyte/numerix'
const index = Numeric.string.find('hello', 'l', true)
console.log(index)
// 3import Numeric from '@neabyte/numerix'
const index = Numeric.string.find('hello', 'z')
console.log(index)
// -1import Numeric from '@neabyte/numerix'
const indices = Numeric.string.find(['hello', 'world'], 'o')
console.log(indices)
// [4,1]