Skip to content

feat: IP列表云区域为0时可以免输入 #20

@vuuv

Description

@vuuv

大部分用户只有直连区域, 因此无需强制填写.
对于无云区域的IP, 自动补齐云区域前缀 0:.

带云区域IP的正则表达式:

([0-9]+:)?(1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])([.](1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])){3}

测试:

s='1.1.1.1
0.0.0.0
1:1.1.1.1
255.255.255.255
256.1.1.1
00.1.1.1
::1
'
patt="([0-9]+:)?(1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])([.](1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])){3}"

echo "$s" | grep -wEo "$patt"
1.1.1.1
0.0.0.0
1:1.1.1.1
255.255.255.255
00.1.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions