Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content
getmac 1.0.0a0 documentation
getmac 1.0.0a0 documentation
  • Installation
  • Usage
  • Command-Line Interface
  • API
    • get_by_method
    • get_default_interface
    • get_instance_from_cache
    • get_mac_address
    • get_method_by_name
    • initialize_method_cache
    • ArpExe
    • ArpFile
    • ArpFreebsd
    • ArpOpenbsd
    • ArpVariousArgs
    • ArpingHost
    • CtypesHost
    • DarwinNetworksetupIface
    • DefaultIfaceFreeBsd
    • DefaultIfaceIpRoute
    • DefaultIfaceLinuxRouteFile
    • DefaultIfaceOpenBsd
    • DefaultIfaceRouteCommand
    • DefaultIfaceRouteGetCommand
    • FcntlIface
    • GetmacExe
    • IfconfigEther
    • IfconfigOther
    • IfconfigWithIfaceArg
    • IpLinkIface
    • IpNeighborShow
    • IpconfigExe
    • LanscanIface
    • Method
    • NetstatIface
    • SysIfaceFile
    • WmicExe
    • Constants
    • Settings
    • Variables
    • call_proc
    • check_command
    • check_path
    • clean_mac
    • fetch_ip_using_dns
    • popen
    • read_file
    • search
  • Changelog
  • Contributing to getmac
  • Security Policy
  • Contributor Covenant Code of Conduct
Back to top
View this page

search¶

getmac.utils.search(regex, text, group_index=0, flags=0)[source]¶

Search for a regular expression in a string, and return the specified group. This is thin wrapper around re.search() with some error handling.

Parameters:
  • regex (str) – regular expression

  • text (str) – data to search

  • group_index (int) – index of value in the groupdict to return, if there are multiple groups in the regex

  • flags (int) – flags to re functions, e.g. re.IGNORECASE

Return type:

Optional[str]

Returns:

The result, or None if the parsing failed or nothing was specified to search.

Next
Changelog
Previous
read_file
Copyright © 2017 - 2026, Christopher Goes
Made with Sphinx and @pradyunsg's Furo
On this page
  • search
    • search()