- The front-end uses JavaScript to parse the IP expression into a real IP lists.
- Used to parse user input IP expressions in the tag.
- Reference JS Scripts in HTML
<script type="text/javascript" charset="utf-8" src="../src/parserIpexp.js"></script>
- Call JS Function API in HTML
<script>
// Support Single or Multiple IP/IP Expression Strings.
let input = "10.1.17.34, 10.10.1.1-3, 10.32.16.44";
let result = parserIpExp(input);
console.log(result);
</script>
- Console Display
[object Object] {
data: ["10.1.17.34", "10.10.1.1", "10.10.1.2", "10.10.1.3", "10.32.16.44"],
state: true
}
- Some Error Demo
--------------------------------------------
parserIpExp("192.168.1.265"); // An invalid ipv4 address.
parserIpExp("192.168.1.10-1"); // Currently only supports from small to large.
parserIpExp("192.168.[1-10].1"); // Currently only supports the continuity of the 4th ip segment.
parserIpExp("192.168.1.1-192.168.1.10"); // This syntax is not currently supported.
--------------------------------------------
[object Object] {
data: [],
state: false
}
--------------------------------------------
CDN online jquery 3.3.1 library is referenced in the example.
v1.0.0