Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
^ ([\w-_ ]+):\n\n +Type: AirPort\n +Hardware.+\n +BSD Device Name: (.+)\n +IPv4 Addresses: (192[\.\d]+)$
/
gm

Description

Purpose:

  • Determine if Wi-Fi is connected, active and running on your Mac.
  • Returns details about connection

The Friendly Name (shown in Network Prefs) The BSD Device Name The IP address

Source Text:

Process output from this Mac shell script:

system_profiler SPNetworkDataType

TAGS: @Mac @Network @WiFi @Wi-Fi

Submitted by JMichaelTX - 8 years ago