I am looking to transform a string representing an IP address, like 10.120.0.1
, into another string representing an ISIS Network ID, such as 49.0001.0101.2000.0001.00
. The section in the middle 010 1.20 00.0 001
corresponds to the first string (I have added spaces for clarity). Each hextet in the ISIS Network ID consists of 4 digits that need to match with the corresponding 3 digits in the IP Address octet. For example, if the number is 53
, it should be converted to 053
to maintain the format.
All IP addresses begin with 10.120.
, so I just need to replace the last 2 octets from the IP Address into the ISIS Network ID.
The goal is to create a dynamic system where inputting a new IP address in a field named loopbackIP
automatically updates the value in the isisNetworkID
field.
This is what I currently have:
49.0001.0101.{{ isisNetworkID }}.00
To achieve this, the remaining values from the input field linked by v-model="loopbackIP"
need to fit within the middle part of the isisNetworkID
following this pattern - xxxx.xxxx
.
I've started with a computed calculation but unsure how to handle the conversion from 4 digits to 3...
const loopbackIP = '10.120.0.1';
const isisNetworkID = computed(() => {
let idaho = '10.120.';
if (loopbackIP.indexOf(idaho)) {
return loopbackIP.slice(7);
} else {
console.log('Nothing is happening');
}
});
I hope this explanation clarifies the issue...