I need to be able to convert a string (IP address) such as this to a string (ISIS Network ID) such as this 49.0001.0101.2000.0001.00. The middle section 010 1.20 00.0 001 corresponds to the first string (I've spaced them out to show the IP address is inside it). You can see that there are 4 digits in each ISIS Network ID hextet that need to correspond to 3 digits in the IP Address octet. A number of 53 for example would have a leading 0 to make 3 digits.

All the IP addresses start with 10.120. so I just need to inject the last 2 octets from the IP Address into the ISIS Network ID.

I need this to be dynamic so when someone types in another ip address into a loopbackIP input, it automatically updates the isisNetworkID field.


49.0001.0101.{{ isisNetworkID }}.00

This needs to take the value from an input v-model="loopbackIP" that I have and translate the remaining values to sit in the middle of that isisNetworkID following this format - xxxx.xxxx.


const loopbackIP = '';

const isisNetworkID = computed(() => {
    let idaho = '10.120.';

    if (loopbackIP.indexOf(idaho)) {
        return loopbackIP.slice(7);
    } else {
        console.log('Nothing is happening');