You are viewing an older version (9.3.0). Go to latest (9.13.0)
{ } Raw JSON

bundles / IPython 9.3.0 / IPython / utils / text / SList / grep

function

IPython.utils.text:SList.grep

source: /IPython/utils/text.py :154

Signature

def   grep ( self pattern : Union[str, Callable[[Any], re.Match[str] | None]] prune : bool = False field : Optional[int] = None )  →  Self

Summary

Return all strings matching 'pattern' (a regex or callable)

Extended Summary

This is case-insensitive. If prune is true, return all items NOT matching the pattern.

If field is specified, the match must occur in the specified whitespace-separated field.

Examples

a.grep( lambda x: x.startswith('C') )
a.grep('Cha.*log', prune=1)
a.grep('chm', field=-1)

Aliases

  • IPython.core.interactiveshell.SList.grep