I would like to extract the IPv4 address only from the output below, after running ipconfig, using Regex.
Connection-specific DNS Suffix . : domain.local
Link-local IPv6 Address . . . . . : fe80::49b6:17f6:f059:1c3d%12
IPv4 Address. . . . . . . . . . . : 192.168.2.180
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.2.254
Therefore I would like to extract the '192.168.2.180' address only.
^ *IPv4 Address[.\\s]*:\\s*([\\d.]+)\\s*$
它不会对IP地址进行任何完整性检查。
There are better ways to parse IP addresses, but this one is simple and grabs only what you need:
http://rubular.com/r/PxEX4Lk56w
\\s+IPv4 Address.*: ([\\d\\.]+)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.