For each element, return the highest index in the string where substring ``sub`` is found, such that ``sub`` is contained in the range [``start``, ``end``). Parameters ---------- a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype sub : array-like, with
(a, sub, start=0, end=None)
| 292 | |
| 293 | @set_module("numpy.strings") |
| 294 | def rfind(a, sub, start=0, end=None): |
| 295 | """ |
| 296 | For each element, return the highest index in the string where |
| 297 | substring ``sub`` is found, such that ``sub`` is contained in the |
| 298 | range [``start``, ``end``). |
| 299 | |
| 300 | Parameters |
| 301 | ---------- |
| 302 | a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype |
| 303 | |
| 304 | sub : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype |
| 305 | The substring to search for. |
| 306 | |
| 307 | start, end : array_like, with any integer dtype |
| 308 | The range to look in, interpreted as in slice notation. |
| 309 | |
| 310 | Returns |
| 311 | ------- |
| 312 | y : ndarray |
| 313 | Output array of ints |
| 314 | |
| 315 | See Also |
| 316 | -------- |
| 317 | str.rfind |
| 318 | |
| 319 | Examples |
| 320 | -------- |
| 321 | >>> import numpy as np |
| 322 | >>> a = np.array(["Computer Science"]) |
| 323 | >>> np.strings.rfind(a, "Science", start=0, end=None) |
| 324 | array([9]) |
| 325 | >>> np.strings.rfind(a, "Science", start=0, end=8) |
| 326 | array([-1]) |
| 327 | >>> b = np.array(["Computer Science", "Science"]) |
| 328 | >>> np.strings.rfind(b, "Science", start=0, end=None) |
| 329 | array([9, 0]) |
| 330 | |
| 331 | """ |
| 332 | end = end if end is not None else MAX |
| 333 | return _rfind_ufunc(a, sub, start, end) |
| 334 | |
| 335 | |
| 336 | @set_module("numpy.strings") |
no outgoing calls
no test coverage detected
searching dependent graphs…