Our app requires users to input an IP Address that falls within the DHCP Scope provided. For example, if the DHCP Scope is 5.5.5.5, users can enter any IP between 5.5.5.2 and 5.5.5.254.
I have set up a JSFiddle with all the necessary elements, but I am facing difficulty creating the ng-pattern for validation: https://jsfiddle.net/spaceninja/6yz09y61/
I believe a RegEx pattern that takes the original IP address as a base and allows for variations in the last octet within the range of 2-254 should work. Something like this:
$scope.regex = /[5][.][5][.][5][.][2-254]/g;
However, I need the RegEx pattern to dynamically adjust based on the initial IP address provided in the data. It should adapt to any valid IP structure received. Here's a sample code snippet:
var originalIP = "192.168.2.3";
var parts = ip.split('.');
var octet1 = parts[0];
var octet2 = parts[1];
var octet3 = parts[2];
var octet4 = parts[3];
If it were possible to incorporate variables in the RegEx pattern, it could potentially look like this:
$scope.regex = /[octet1][.][octet2][.][octet3][.][2-254]/g;
Although using variables directly in RegEx might not be feasible, I hope this clarifies the requirements for the pattern needed.