Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
vuuv opened this issue Jun 23, 2021 · 0 comments
Open

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

vuuv opened this issue Jun 23, 2021 · 0 comments

Comments

@vuuv
Copy link

vuuv commented Jun 23, 2021

大部分用户只有直连区域, 因此无需强制填写.
对于无云区域的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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant